Exception: Orchestrate::API::BaseError

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

Overview

Base class for Errors from Orchestrate.

Direct Known Subclasses

RequestError, ServiceError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ BaseError

Returns a new instance of BaseError.

Parameters:

  • response (Faraday::Response)

    The response that caused the error.



17
18
19
20
21
22
23
24
# File 'lib/orchestrate/api/errors.rb', line 17

def initialize(response)
  @response = response
  if response.headers['Content-Type'] == 'application/json' && response.body
    super(response.body['message'])
  else
    super(response.body)
  end
end

Instance Attribute Details

#responseFaraday::Response (readonly)

Returns The response that caused the error.

Returns:

  • (Faraday::Response)

    The response that caused the error.



14
15
16
# File 'lib/orchestrate/api/errors.rb', line 14

def response
  @response
end

Class Method Details

.codeString

class-level attr-reader for the error's code.

Returns:

  • (String)

    API's error code.



11
# File 'lib/orchestrate/api/errors.rb', line 11

def self.code; @code; end

.statusInteger

class-level attr-reader for the error's response code.

Returns:

  • (Integer)

    Status code for error.



7
# File 'lib/orchestrate/api/errors.rb', line 7

def self.status; @status; end