class Ponominalu::Error

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

Attributes

error_code[R]

An error code. @return [Fixnum]

Public Class Methods

new(data) click to toggle source

An exception is initialized by the data from response mash. @param [Hash] data Error data.

# 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

Public Instance Methods

message() click to toggle source

A full description of the error. @return [String]

# 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