Exception: Tango::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/tango/error.rb

Direct Known Subclasses

ClientError, DecodeError, ServerError

Defined Under Namespace

Classes: ClientError, DecodeError, InsFunds, InsInv, InvCredential, InvInput, ServerError, SysError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception = $!) ⇒ Tango::Error

Initializes a new Error object

Parameters:

  • exception (Exception, String) (defaults to: $!)


19
20
21
22
# File 'lib/tango/error.rb', line 19

def initialize(exception = $!)
  @wrapped_exception = exception
  exception.respond_to?(:backtrace) ? super(exception.message) : super(exception.to_s)
end

Instance Attribute Details

#status_codeObject

Returns the value of attribute status_code.



3
4
5
# File 'lib/tango/error.rb', line 3

def status_code
  @status_code
end

Class Method Details

.from_status_code(status_code) ⇒ Tango::Error

Creates a new Error object from status_code

Parameters:

  • status_code (Integer)

    HTTP response status code

Returns:



9
10
11
12
13
# File 'lib/tango/error.rb', line 9

def self.from_status_code(status_code)
  ex = new("Error: #{status_code}")
  ex.status_code = status_code
  ex
end

Instance Method Details

#backtraceObject



24
25
26
# File 'lib/tango/error.rb', line 24

def backtrace
  @wrapped_exception.respond_to?(:backtrace) ? @wrapped_exception.backtrace : super
end