class WorldpayCnp::Error

Constants

BadGateway

Raised on the HTTP status code 502

ClientError

Raised on a 4xx HTTP status code

ERRORS_BY_STATUS
ExpectationFailed

Raised on the HTTP status code 417

Forbidden

Raised on the HTTP status code 403

GatewayTimeout

Raised on the HTTP status code 504

InternalServerError

Raised on the HTTP status code 500

InvalidFormatError
MethodNotAllowed

Raised on the HTTP status code 405

NotFound

Raised on the HTTP status code 404

ServerError

Raised on a 5xx HTTP status code

ServiceUnavailable

Raised on the HTTP status code 503

XmlParseError

Attributes

raw_response[R]

The raw HTTP response, if applicable

@return [String]

response_code[R]

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..." />

@return [String]

Public Class Methods

from_http_response(body, status) click to toggle source

Create a new error from an HTTP response body and status

@param body [String] @param status [Integer] @return [WorldpayCnp::Error]

# 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
new(message, response_code: '', raw_response: '') click to toggle source

Initializes a new Error object

@param message [Exception, String] @param code [String] @param raw_http_response [String] @return [WorldpayCnp::Error]

Calls superclass method
# File lib/worldpay_cnp/error.rb, line 79
def initialize(message, response_code: '', raw_response: '')
  @response_code = response_code
  @raw_response = raw_response
  super(message)
end