Exception: Swiftner::Error

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

Overview

Encapsulates all errors that can be raised by the Swiftner API

Direct Known Subclasses

Forbidden, InternalError, NotFound, Unauthorized

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, response: nil) ⇒ Error

Returns a new instance of Error.



14
15
16
17
# File 'lib/swiftner/error.rb', line 14

def initialize(message, response: nil)
  @response = response
  super(message)
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/swiftner/error.rb', line 6

def response
  @response
end

Class Method Details

.from_response(response) ⇒ Object



8
9
10
11
12
# File 'lib/swiftner/error.rb', line 8

def self.from_response(response)
  return new(response["detail"], response: response) if response.key?("detail")

  new(response.to_s, response: response)
end