Exception: Contaazul::Error

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

Overview

Custom error class for rescuing from all Contaazul API errors

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ Error

Returns a new instance of Error.



4
5
6
7
# File 'lib/contaazul/error.rb', line 4

def initialize(response=nil)
  @response = response
  super(build_error_message)
end

Instance Method Details

#response_bodyObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/contaazul/error.rb', line 9

def response_body
  @response_body ||=
    if (body = @response[:body]) && !body.empty?
      if body.is_a?(String)
        MultiJson.load(body, :symbolize_keys => true)
      else
        body
      end
    else
      nil
    end
end