Exception: SynapsePayments::Error
- Inherits:
-
StandardError
- Object
- StandardError
- SynapsePayments::Error
- Defined in:
- lib/synapse_payments/error.rb
Constant Summary collapse
- ClientError =
Raised on a 4xx HTTP status code
Class.new(self)
- BadRequest =
Raised on the HTTP status code 400
Class.new(ClientError)
Class.new(ClientError)
- RequestDeclined =
Raised on the HTTP status code 402
Class.new(ClientError)
- Forbidden =
Raised on the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised on the HTTP status code 404
Class.new(ClientError)
- NotAcceptable =
Raised on the HTTP status code 406
Class.new(ClientError)
- Conflict =
Raised on the HTTP status code 409
Class.new(ClientError)
- UnsupportedMediaType =
Raised on the HTTP status code 415
Class.new(ClientError)
- UnprocessableEntity =
Raised on the HTTP status code 422
Class.new(ClientError)
- TooManyRequests =
Raised on the HTTP status code 429
Class.new(ClientError)
- ServerError =
Raised on a 5xx HTTP status code
Class.new(self)
- InternalServerError =
Raised on the HTTP status code 500
Class.new(ServerError)
- BadGateway =
Raised on the HTTP status code 502
Class.new(ServerError)
Class.new(ServerError)
- GatewayTimeout =
Raised on the HTTP status code 504
Class.new(ServerError)
- ERRORS =
{ 400 => SynapsePayments::Error::BadRequest, 401 => SynapsePayments::Error::Unauthorized, 402 => SynapsePayments::Error::RequestDeclined, 403 => SynapsePayments::Error::Forbidden, 404 => SynapsePayments::Error::NotFound, 406 => SynapsePayments::Error::NotAcceptable, 409 => SynapsePayments::Error::Conflict, 415 => SynapsePayments::Error::UnsupportedMediaType, 422 => SynapsePayments::Error::UnprocessableEntity, 429 => SynapsePayments::Error::TooManyRequests, 500 => SynapsePayments::Error::InternalServerError, 502 => SynapsePayments::Error::BadGateway, 503 => SynapsePayments::Error::ServiceUnavailable, 504 => SynapsePayments::Error::GatewayTimeout, }
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
The SynapsePay API Error Code.
-
#response ⇒ Hash
readonly
The JSON HTTP response in Hash form.
Class Method Summary collapse
-
.error_from_response(body, code) ⇒ SynapsePayments::Error
Create a new error from an HTTP response.
Instance Method Summary collapse
-
#initialize(message: '', code: nil, response: {}) ⇒ SynapsePayments::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message: '', code: nil, response: {}) ⇒ SynapsePayments::Error
Initializes a new Error object
110 111 112 113 114 |
# File 'lib/synapse_payments/error.rb', line 110 def initialize(message: '', code: nil, response: {}) super() @code = code @response = response end |
Instance Attribute Details
#code ⇒ Integer (readonly)
The SynapsePay API Error Code
71 72 73 |
# File 'lib/synapse_payments/error.rb', line 71 def code @code end |
#response ⇒ Hash (readonly)
The JSON HTTP response in Hash form
76 77 78 |
# File 'lib/synapse_payments/error.rb', line 76 def response @response end |
Class Method Details
.error_from_response(body, code) ⇒ SynapsePayments::Error
Create a new error from an HTTP response
84 85 86 87 88 |
# File 'lib/synapse_payments/error.rb', line 84 def error_from_response(body, code) klass = ERRORS[code] || SynapsePayments::Error , error_code = parse_error(body) klass.new(message: , code: error_code, response: body) end |