Exception: MasterCard::Core::Exceptions::APIException
- Inherits:
-
StandardError
- Object
- StandardError
- MasterCard::Core::Exceptions::APIException
- Includes:
- Model
- Defined in:
- lib/mastercard/core/exceptions.rb
Overview
APIException
Constant Summary collapse
- @@mapping =
{100 => "Continue", 101 => "Switching Protocols", 102 => "Processing", 200 => "OK", 201 => "Created", 202 => "Accepted", 203 => "Non-Authoritative Information", 204 => "No Content", 205 => "Reset Content", 206 => "Partial Content", 207 => "Multi-Status", 300 => "Multiple Choices", 301 => "Moved Permanently", 302 => "Found", 303 => "See Other", 304 => "Not Modified", 305 => "Use Proxy", 306 => "(Unused)", 307 => "Temporary Redirect", 308 => "Permanent Redirect", 400 => "Bad Request", 401 => "Unauthorized", 402 => "Payment Required", 403 => "Forbidden", 404 => "Not Found", 405 => "Method Not Allowed", 406 => "Not Acceptable", 407 => "Proxy Authentication Required", 408 => "Request Timeout", 409 => "Conflict", 410 => "Gone", 411 => "Length Required", 412 => "Precondition Failed", 413 => "Request Entity Too Large", 414 => "Request-URI Too Long", 415 => "Unsupported Media Type", 416 => "Requested Range Not Satisfiable", 417 => "Expectation Failed", 418 => "I'm a teapot", 419 => "Authentication Timeout", 420 => "Enhance Your Calm", 422 => "Unprocessable Entity", 423 => "Locked", 424 => "Failed Dependency", 425 => "Unordered Collection", 426 => "Upgrade Required", 428 => "Precondition Required", 429 => "Too Many Requests", 431 => "Request Header Fields Too Large", 444 => "No Response", 449 => "Retry With", 450 => "Blocked by Windows Parental Controls", 451 => "Unavailable For Legal Reasons", 494 => "Request Header Too Large", 495 => "Cert Error", 496 => "No Cert", 497 => "HTTP to HTTPS", 499 => "Client Closed Request", 500 => "Internal Server Error", 501 => "Not Implemented", 502 => "Bad Gateway", 503 => "Service Unavailable", 504 => "Gateway Timeout", 505 => "HTTP Version Not Supported", 506 => "Variant Also Negotiates", 507 => "Insufficient Storage", 508 => "Loop Detected", 509 => "Bandwidth Limit Exceeded", 510 => "Not Extended", 511 => "Network Authentication Required", 598 => "Network read timeout error", 599 => "Network connect timeout error"}
Instance Method Summary collapse
- #describe ⇒ Object
- #getError ⇒ Object
- #getErrorSize ⇒ Object
- #getHttpStatus ⇒ Object
- #getMessage ⇒ Object
- #getRawErrorData ⇒ Object
- #getReasonCode ⇒ Object
- #getSource ⇒ Object
-
#initialize(message, http_status = nil, error_data = nil) ⇒ APIException
constructor
Base Class for all the API exceptions.
- #parseError(index) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message, http_status = nil, error_data = nil) ⇒ APIException
Base Class for all the API exceptions
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mastercard/core/exceptions.rb', line 43 def initialize(,http_status=nil, error_data=nil) #Call the base class constructor super() @message = @http_status = http_status @message = unless http_status.nil? @message = @@mapping[http_status] end @message = @description = nil @reason_code = nil @source = nil @raw_error_data = nil @error = nil @errors = [] parseRawErrorData(error_data) parseErrors(error_data) parseError(0) end |
Instance Method Details
#describe ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/mastercard/core/exceptions.rb', line 111 def describe() exception = self.class.name exception << ": \"" exception << getMessage() exception << "\" (http_status: " exception << "%s" % getHttpStatus() errorCode = getReasonCode() unless errorCode.nil? exception << ", reason_code: " exception << "%s" % getReasonCode() end exception << ")" return exception end |
#getError ⇒ Object
79 80 81 |
# File 'lib/mastercard/core/exceptions.rb', line 79 def getError() return @error end |
#getErrorSize ⇒ Object
83 84 85 |
# File 'lib/mastercard/core/exceptions.rb', line 83 def getErrorSize() return @errors.size end |
#getHttpStatus ⇒ Object
95 96 97 |
# File 'lib/mastercard/core/exceptions.rb', line 95 def getHttpStatus() return @http_status end |
#getMessage ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/mastercard/core/exceptions.rb', line 87 def getMessage() if @description.nil? return @message else return @description end end |
#getRawErrorData ⇒ Object
107 108 109 |
# File 'lib/mastercard/core/exceptions.rb', line 107 def getRawErrorData() return @raw_error_data end |
#getReasonCode ⇒ Object
99 100 101 |
# File 'lib/mastercard/core/exceptions.rb', line 99 def getReasonCode() return @reason_code end |
#getSource ⇒ Object
103 104 105 |
# File 'lib/mastercard/core/exceptions.rb', line 103 def getSource() return @source end |
#parseError(index) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/mastercard/core/exceptions.rb', line 72 def parseError(index) if @errors.any? && index >= 0 && index < getErrorSize() @error = @errors[index] parseErrorFromMap() end end |
#to_s ⇒ Object
126 127 128 |
# File 'lib/mastercard/core/exceptions.rb', line 126 def to_s() return '%s' % describe() end |