Exception: BookingSync::API::Error

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

Overview

Class for rescuing all BS API errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
# File 'lib/bookingsync/api/error.rb', line 6

def initialize(response)
  @status  = response.status
  @headers = response.headers
  @body    = response.body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/bookingsync/api/error.rb', line 4

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/bookingsync/api/error.rb', line 4

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/bookingsync/api/error.rb', line 4

def status
  @status
end

Instance Method Details

#message(message = self.class) ⇒ Object



12
13
14
15
16
17
# File 'lib/bookingsync/api/error.rb', line 12

def message(message = self.class)
  %{#{message}
HTTP status code : #{status}
Headers          : #{headers}
Body             : #{body}}
end