Exception: DuffelAPI::Errors::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, response = nil) ⇒ Error

Returns a new instance of Error.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
# File 'lib/duffel_api/errors/error.rb', line 8

def initialize(error, response = nil)
  raise ArgumentError, "Duffel errors expect a hash" unless error.is_a?(Hash)

  @error = error
  @response = response

  super(error)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

Instance Method Details

#api_responseObject



49
50
51
# File 'lib/duffel_api/errors/error.rb', line 49

def api_response
  APIResponse.new(@response)
end

#codeObject



37
38
39
# File 'lib/duffel_api/errors/error.rb', line 37

def code
  @error["code"]
end

#documentation_urlObject



17
18
19
# File 'lib/duffel_api/errors/error.rb', line 17

def documentation_url
  @error["documentation_url"]
end

#messageObject



25
26
27
# File 'lib/duffel_api/errors/error.rb', line 25

def message
  @error["message"]
end

#request_idObject



41
42
43
# File 'lib/duffel_api/errors/error.rb', line 41

def request_id
  @error["request_id"]
end

#sourceObject



45
46
47
# File 'lib/duffel_api/errors/error.rb', line 45

def source
  @error["source"]
end

#titleObject



21
22
23
# File 'lib/duffel_api/errors/error.rb', line 21

def title
  @error["title"]
end

#to_sObject



29
30
31
# File 'lib/duffel_api/errors/error.rb', line 29

def to_s
  @error["message"]
end

#typeObject



33
34
35
# File 'lib/duffel_api/errors/error.rb', line 33

def type
  @error["type"]
end