class Fakturan::WithResponse

Attributes

response[R]

Public Class Methods

new(ex, response = nil) click to toggle source
Calls superclass method
# 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.message)
    @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

Public Instance Methods

backtrace() click to toggle source
Calls superclass method
# File lib/fakturan_nu/error.rb, line 30
def backtrace
  if @wrapped_exception
    @wrapped_exception.backtrace
  else
    super
  end
end
inspect() click to toggle source
# File lib/fakturan_nu/error.rb, line 38
def inspect
  %(#<#{self.class}>)
end
status() click to toggle source
# File lib/fakturan_nu/error.rb, line 11
def status
  response[:status]
end