Exception: Booker::Error

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

Direct Known Subclasses

InvalidApiCredentials

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url: nil, request: nil, response: nil) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/booker/errors.rb', line 5

def initialize(url: nil, request: nil, response: nil)
  if request.present?
    self.request = request
  end

  if response.present?
    self.response = response
    error = response
    error = response["Fault"]["Detail"]["InternalErrorFault"] if response["Fault"]
    self.error = error['error'] || error['ErrorMessage']
    self.description = error['error_description']
    self.argument_errors = error["ArgumentErrors"].map { |a| { :attr => a["ArgumentName"], :message => a["ErrorMessage"] } } unless error["ArgumentErrors"].nil?
  end

  self.url = url
end

Instance Attribute Details

#argument_errorsObject

Returns the value of attribute argument_errors.



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

def argument_errors
  @argument_errors
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#requestObject

Returns the value of attribute request.



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

def request
  @request
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end