Exception: ShipReal::Error
- Inherits:
-
StandardError
- Object
- StandardError
- ShipReal::Error
- Defined in:
- lib/shipreal.rb
Overview
Any non-2xx response, carrying the RFC 9457 problem details the server sent.
Branch on #type rather than #status: the status says a request failed, the type says which failure it was, and only the second is stable enough to switch on.
Instance Attribute Summary collapse
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#problem ⇒ Object
readonly
Returns the value of attribute problem.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(status, problem, url) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(status, problem, url) ⇒ Error
Returns a new instance of Error.
43 44 45 46 47 48 49 50 51 |
# File 'lib/shipreal.rb', line 43 def initialize(status, problem, url) @status = status @problem = problem @url = url @type = problem && problem["type"] @title = problem && problem["title"] @detail = problem && problem["detail"] super(@detail || @title || "Request failed with #{status}") end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
41 42 43 |
# File 'lib/shipreal.rb', line 41 def detail @detail end |
#problem ⇒ Object (readonly)
Returns the value of attribute problem.
41 42 43 |
# File 'lib/shipreal.rb', line 41 def problem @problem end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
41 42 43 |
# File 'lib/shipreal.rb', line 41 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
41 42 43 |
# File 'lib/shipreal.rb', line 41 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
41 42 43 |
# File 'lib/shipreal.rb', line 41 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
41 42 43 |
# File 'lib/shipreal.rb', line 41 def url @url end |