Exception: WorldpayCnp::Error
- Inherits:
-
StandardError
- Object
- StandardError
- WorldpayCnp::Error
- Defined in:
- lib/worldpay_cnp/error.rb
Constant Summary collapse
- InvalidFormatError =
Class.new(self)
- XmlParseError =
Class.new(self)
- ClientError =
Raised on a 4xx HTTP status code
Class.new(self)
- Forbidden =
Raised on the HTTP status code 403
Class.new(ClientError)
- NotFound =
Raised on the HTTP status code 404
Class.new(ClientError)
- MethodNotAllowed =
Raised on the HTTP status code 405
Class.new(ClientError)
- ExpectationFailed =
Raised on the HTTP status code 417
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_BY_STATUS =
{ 403 => Error::Forbidden, 404 => Error::NotFound, 405 => Error::MethodNotAllowed, 417 => Error::ExpectationFailed, 500 => Error::InternalServerError, 502 => Error::BadGateway, 503 => Error::ServiceUnavailable, 504 => Error::GatewayTimeout, }
Instance Attribute Summary collapse
-
#raw_response ⇒ String
readonly
The raw HTTP response, if applicable.
-
#response_code ⇒ String
readonly
The response code in the XML root element.
Class Method Summary collapse
-
.from_http_response(body, status) ⇒ WorldpayCnp::Error
Create a new error from an HTTP response body and status.
Instance Method Summary collapse
-
#initialize(message, response_code: '', raw_response: '') ⇒ WorldpayCnp::Error
constructor
Initializes a new Error object.
Constructor Details
#initialize(message, response_code: '', raw_response: '') ⇒ WorldpayCnp::Error
Initializes a new Error object
79 80 81 82 83 |
# File 'lib/worldpay_cnp/error.rb', line 79 def initialize(, response_code: '', raw_response: '') @response_code = response_code @raw_response = raw_response super() end |
Instance Attribute Details
#raw_response ⇒ String (readonly)
The raw HTTP response, if applicable
62 63 64 |
# File 'lib/worldpay_cnp/error.rb', line 62 def raw_response @raw_response end |
#response_code ⇒ String (readonly)
The response code in the XML root element. The value of the response attribute in the following example:
<cnpOnlineResponse version=“12.17” xmlns=“www.vantivcnp.com/schema”
response="1" message="Error validating xml..." />
71 72 73 |
# File 'lib/worldpay_cnp/error.rb', line 71 def response_code @response_code end |
Class Method Details
.from_http_response(body, status) ⇒ WorldpayCnp::Error
Create a new error from an HTTP response body and status
53 54 55 56 |
# File 'lib/worldpay_cnp/error.rb', line 53 def from_http_response(body, status) klass = ERRORS_BY_STATUS[status] || self klass.new("Service error (Status: #{status})", raw_response: body) end |