Exception: PassaporteWeb::Client::Exception

Inherits:
StandardError
  • Object
show all
Defined in:
lib/passaporte_web/client/exception.rb

Overview

Exception class raised whenever the underlying client receives an error response.

API

Documentation:

Instance Method Summary collapse

Constructor Details

#initialize(message, response) ⇒ Exception

Creates an instance of this exception.

Parameters:

  • message (String)

    The exception message.

  • response (#status, #headers, #body)

    The client's HTTP response object.


11
12
13
14
# File 'lib/passaporte_web/client/exception.rb', line 11

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

Instance Method Details

#bodyInteger

Returns HTTP response's body.

Returns:

  • (Integer)

    HTTP response's body.


27
28
29
# File 'lib/passaporte_web/client/exception.rb', line 27

def body
  @response ? @response.body : ''
end

#headersInteger

Returns HTTP response's headers.

Returns:

  • (Integer)

    HTTP response's headers.


22
23
24
# File 'lib/passaporte_web/client/exception.rb', line 22

def headers
  @response.headers if @response
end

#statusInteger

Returns HTTP response's status.

Returns:

  • (Integer)

    HTTP response's status.


17
18
19
# File 'lib/passaporte_web/client/exception.rb', line 17

def status
  @response.status if @response
end