Exception: Buckaruby::ApiException

Inherits:
BuckarooException show all
Defined in:
lib/buckaruby/exception.rb

Overview

Exception raised when an API call to Buckaroo results in a “Fail”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ ApiException

Returns a new instance of ApiException.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/buckaruby/exception.rb', line 12

def initialize(params = {})
  @params = params

  message =
    if status_message && status_code
      "API request failed: #{status_message} (#{status_code})"
    elsif error_message
      "API request failed: #{error_message}"
    else
      'API request failed'
    end

  super(message)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



10
11
12
# File 'lib/buckaruby/exception.rb', line 10

def params
  @params
end

Instance Method Details

#error_messageObject



35
36
37
# File 'lib/buckaruby/exception.rb', line 35

def error_message
  params[:brq_apierrormessage]
end

#status_codeObject



31
32
33
# File 'lib/buckaruby/exception.rb', line 31

def status_code
  params[:brq_statuscode]
end

#status_messageObject



27
28
29
# File 'lib/buckaruby/exception.rb', line 27

def status_message
  params[:brq_statusmessage]
end