class SynapsePayments::Error
Constants
- BadGateway
Raised on the HTTP status code 502
- BadRequest
Raised on the HTTP status code 400
- ClientError
Raised on a 4xx HTTP status code
- Conflict
Raised on the HTTP status code 409
- ERRORS
- Forbidden
Raised on the HTTP status code 403
- GatewayTimeout
Raised on the HTTP status code 504
- InternalServerError
Raised on the HTTP status code 500
- NotAcceptable
Raised on the HTTP status code 406
- NotFound
Raised on the HTTP status code 404
- RequestDeclined
Raised on the HTTP status code 402
- ServerError
Raised on a 5xx HTTP status code
Raised on the HTTP status code 503
- TooManyRequests
Raised on the HTTP status code 429
Raised on the HTTP status code 401
- UnprocessableEntity
Raised on the HTTP status code 422
- UnsupportedMediaType
Raised on the HTTP status code 415
Attributes
The SynapsePay API Error
Code
@return [Integer]
The JSON HTTP response in Hash form
@return [Hash]
Public Class Methods
Create a new error from an HTTP response
@param body [String] @param code [Integer] @return [SynapsePayments::Error]
# File lib/synapse_payments/error.rb, line 84 def error_from_response(body, code) klass = ERRORS[code] || SynapsePayments::Error message, error_code = parse_error(body) klass.new(message: message, code: error_code, response: body) end
Initializes a new Error
object
@param message [Exception, String] @param code [Integer] @param response [Hash] @return [SynapsePayments::Error]
# File lib/synapse_payments/error.rb, line 110 def initialize(message: '', code: nil, response: {}) super(message) @code = code @response = response end
Private Class Methods
# File lib/synapse_payments/error.rb, line 92 def parse_error(body) if body.nil? || body.empty? ['', nil] elsif body.is_a?(Hash) && body[:error].is_a?(Hash) [body[:error][:en], body[:error_code]] else [body.to_s, nil] end end