Exception: Omie::RequestError
Overview
This exception must be used for failed requests with JSON responses from Omie.
Omie does not use the semantic value of HTTP status codes. It always returns the 500 error code to any failed request that has an associated message to the client, which was supposed to use the 400* error codes. Moreover, the error message is provided through a returned JSON object that has the keys ‘faultstring’ and ‘faultcode’. Such data is used in the exception message for a better understanding of the error.
Instance Attribute Summary
Attributes inherited from Error
Instance Method Summary collapse
-
#after_initialize ⇒ Object
Sets fault_string and fault_code based on Omie’s responses for failed requests.
- #default_message ⇒ Object
-
#message ⇒ Object
Return the custom message or a default message with the fault code and string.
Methods inherited from Error
Constructor Details
This class inherits a constructor from Omie::Error
Instance Method Details
#after_initialize ⇒ Object
Sets fault_string and fault_code based on Omie’s responses for failed requests.
35 36 37 38 39 40 41 |
# File 'lib/omie/error.rb', line 35 def after_initialize return unless @response json = JSON.parse(@response.body) @fault_string = json['faultstring'] @fault_code = json['faultcode'] end |
#default_message ⇒ Object
49 50 51 |
# File 'lib/omie/error.rb', line 49 def "Omie returned the error #{@fault_code}: '#{@fault_string}'" end |
#message ⇒ Object
Return the custom message or a default message with the fault code and string.
45 46 47 |
# File 'lib/omie/error.rb', line 45 def @message || end |