Exception: Zephyr::FailedRequest

Inherits:
StandardError
  • Object
show all
Defined in:
lib/zephyr/failed_request.rb

Overview

Raised when a request fails due to either a timeout or when the expected response code does not match the actual response code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FailedRequest

The following options are required:

method - The HTTP method used for the request. uri - The uri of the request. expected_code - The expected response code for the request. timeout - The timeout (in milliseconds) for the request. response - The response.



14
15
16
17
18
19
20
21
22
# File 'lib/zephyr/failed_request.rb', line 14

def initialize(options)
  @method        = options[:method].to_s.upcase
  @uri           = options[:uri]
  @expected_code = options[:expected_code]
  @timeout       = options[:timeout]
  @response      = options[:response]

  super "#{@method} #{@uri} - #{error_message}"
end

Instance Attribute Details

#expected_codeObject (readonly)

Returns the value of attribute expected_code.



5
6
7
# File 'lib/zephyr/failed_request.rb', line 5

def expected_code
  @expected_code
end

#methodObject (readonly)

Returns the value of attribute method.



5
6
7
# File 'lib/zephyr/failed_request.rb', line 5

def method
  @method
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/zephyr/failed_request.rb', line 5

def response
  @response
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



5
6
7
# File 'lib/zephyr/failed_request.rb', line 5

def timeout
  @timeout
end

#uriObject (readonly)

Returns the value of attribute uri.



5
6
7
# File 'lib/zephyr/failed_request.rb', line 5

def uri
  @uri
end

Instance Method Details

#timed_out?Boolean

Returns whether the request timed out.

Returns:

  • (Boolean)


25
26
27
# File 'lib/zephyr/failed_request.rb', line 25

def timed_out?
  @response.timed_out? || @response.code == 0
end