Exception: Ponominalu::Error

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

Overview

An exception raised by ‘Ponominalu::Response` when given a response with an error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Error

An exception is initialized by the data from response mash.

Parameters:

  • data (Hash)

    Error data.



9
10
11
12
13
14
15
# File 'lib/ponominalu/error.rb', line 9

def initialize(data)
  @error_code   = data.code
  @error_msg    = data.message
  @method_name  = data.method_name
  @session      = data.session
  @params       = data.params
end

Instance Attribute Details

#error_codeFixnum (readonly)

An error code.

Returns:

  • (Fixnum)


6
7
8
# File 'lib/ponominalu/error.rb', line 6

def error_code
  @error_code
end

Instance Method Details

#messageString

A full description of the error.

Returns:

  • (String)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ponominalu/error.rb', line 19

def message
  message = "Ponominalu returned an error #{@error_code}: '#{@error_msg}'"\
            " after calling method '#{@method_name}'"

  if (@params.empty?)
    message << " without parameters."
  else
    message << " with parameters #{@params.inspect}."
  end
  message << " App session is '#{@session}'."
  message
end