Exception: SlimpayClient::Error
- Inherits:
-
StandardError
- Object
- StandardError
- SlimpayClient::Error
- Defined in:
- lib/slimpay_client/error.rb
Overview
To display SlimpayClient error messages with the HTTP code.
Possible API errors
-
code: 906 message: “Error : Could not find acceptable representation”
-
code: 906 message: “Error : Request method ‘POST’ not supported”
-
code: 906 message: “Error : Content type ‘application/x-www-form-urlencoded’ not supported”
-
code: 904 message: “Access denied : cannot access creditor democreditor”
-
error:“invalid_token”, error_description: “Invalid access token: 1234-123456-abcdef-123456”
-
code: 205, message: “Client data are inconsistent : missing query parameters creditorReference and/or rum”
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
-
.empty ⇒ Object
If the HTTP response is nil or empty returns an actual message.
Instance Method Summary collapse
-
#initialize(http_response) ⇒ Error
constructor
Returns either formated error with its HTTP code or the raw HTTP response.
- #to_s ⇒ Object
Constructor Details
#initialize(http_response) ⇒ Error
Returns either formated error with its HTTP code or the raw HTTP response.
Arguments:
http_response: (HTTParty::Response)
21 22 23 24 25 26 27 28 |
# File 'lib/slimpay_client/error.rb', line 21 def initialize(http_response) if defined?(http_response.code) display_http_error(http_response) else @message = JSON.parse(http_response.body) end fail self, @message.to_s end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 13 14 |
# File 'lib/slimpay_client/error.rb', line 12 def @message end |
Class Method Details
.empty ⇒ Object
If the HTTP response is nil or empty returns an actual message.
14 15 16 |
# File 'lib/slimpay_client/error.rb', line 14 def self.empty @message = {code: 418, message: 'The answer was empty.'} end |
Instance Method Details
#to_s ⇒ Object
30 31 32 |
# File 'lib/slimpay_client/error.rb', line 30 def to_s @message end |