Exception: Brightpearl::RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/brightpearl/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, response: nil, status: nil) ⇒ RequestError

Returns a new instance of RequestError.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/brightpearl/errors.rb', line 4

def initialize(msg, response: nil, status: nil)
  if response["errors"] && response["errors"].size == 1 # If error is easily identifiable then set it as the Error message
    error = response["errors"][0]["message"]
    @code = response["errors"][0]["code"]
    super(error)
  else
    super(msg)
  end
  @response = response
  @status = status
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/brightpearl/errors.rb', line 3

def code
  @code
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/brightpearl/errors.rb', line 3

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/brightpearl/errors.rb', line 3

def status
  @status
end