Module: Bibox::Rest::Errors

Included in:
Client
Defined in:
lib/bibox/rest/errors.rb

Instance Method Summary collapse

Instance Method Details

#error?(response) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/bibox/rest/errors.rb', line 5

def error?(response)
  if response.is_a?(Hash) && response.has_key?("error")
    error     =   response.fetch("error", {})
    code      =   error.fetch("code", nil)
    message   =   error.fetch("msg", nil)
    ::Bibox::Errors::MAPPING.fetch(code, nil)&.call
  end
end