Exception: Fakturan::WithResponse
- Defined in:
- lib/fakturan_nu/error.rb
Direct Known Subclasses
AccessDenied, ClientError, ParseError, ResourceNotFound, ServerError
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #backtrace ⇒ Object
-
#initialize(ex, response = nil) ⇒ WithResponse
constructor
A new instance of WithResponse.
- #inspect ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(ex, response = nil) ⇒ WithResponse
Returns a new instance of WithResponse.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fakturan_nu/error.rb', line 15 def initialize(ex, response = nil) @wrapped_exception = nil @response = response if ex.respond_to?(:backtrace) # If ex behaves like an Exception super(ex.) @wrapped_exception = ex elsif ex.respond_to?(:each_key) # If ex behaves like a Hash super("the server responded with status #{ex[:status]} - #{ex[:body]}") @response = ex else super(ex.to_s) end end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/fakturan_nu/error.rb', line 9 def response @response end |
Instance Method Details
#backtrace ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/fakturan_nu/error.rb', line 30 def backtrace if @wrapped_exception @wrapped_exception.backtrace else super end end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/fakturan_nu/error.rb', line 38 def inspect %(#<#{self.class}>) end |
#status ⇒ Object
11 12 13 |
# File 'lib/fakturan_nu/error.rb', line 11 def status response[:status] end |