Exception: Dolibarr::Api::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/dolibarr-api/api_error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, headers: nil, body: nil, response: nil) ⇒ ApiError

Returns a new instance of ApiError.



7
8
9
10
11
12
13
# File 'lib/dolibarr-api/api_error.rb', line 7

def initialize(message = nil, status: nil, headers: nil, body: nil, response: nil)
  @status = status
  @headers = headers
  @body = body
  @response = response
  super(message || "HTTP #{status}")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/dolibarr-api/api_error.rb', line 5

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/dolibarr-api/api_error.rb', line 5

def headers
  @headers
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/dolibarr-api/api_error.rb', line 5

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/dolibarr-api/api_error.rb', line 5

def status
  @status
end

Class Method Details

.from(response) ⇒ Object



15
16
17
# File 'lib/dolibarr-api/api_error.rb', line 15

def self.from(response)
  new(status: response.status, headers: response.headers, body: response.body, response: response)
end