Exception: T2Server::UnexpectedServerResponse
- Inherits:
-
T2ServerError
- Object
- RuntimeError
- T2ServerError
- T2Server::UnexpectedServerResponse
- Defined in:
- lib/t2-server/exceptions.rb
Overview
Raised when there is an unexpected response from the server. This does not necessarily indicate a problem with the server.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
The response body of this error.
-
#code ⇒ Object
readonly
The HTTP error code of this error.
-
#method ⇒ Object
readonly
The method that was called to produce this error.
-
#path ⇒ Object
readonly
The path of the URI that returned this error.
Instance Method Summary collapse
-
#initialize(method, path, response) ⇒ UnexpectedServerResponse
constructor
Create a new UnexpectedServerResponse with details of which HTTP method was called, the path that it was called on and the specified unexpected response.
Constructor Details
#initialize(method, path, response) ⇒ UnexpectedServerResponse
Create a new UnexpectedServerResponse with details of which HTTP method was called, the path that it was called on and the specified unexpected response. The response to be passed in is that which was returned by a call to Net::HTTP#request.
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/t2-server/exceptions.rb', line 103 def initialize(method, path, response) @method = method @path = path @code = response.code @body = response.body.to_s @body = @body.empty? ? "<none>" : "#{response.body}" = "Unexpected server response:\n Method: #{@method}\n Path: "\ "#{@path}\n Code: #{@code}\n Body: #{@body}" super end |
Instance Attribute Details
#body ⇒ Object (readonly)
The response body of this error. If the server did not supply one then this will be “<none>”.
97 98 99 |
# File 'lib/t2-server/exceptions.rb', line 97 def body @body end |
#code ⇒ Object (readonly)
The HTTP error code of this error.
93 94 95 |
# File 'lib/t2-server/exceptions.rb', line 93 def code @code end |
#method ⇒ Object (readonly)
The method that was called to produce this error.
87 88 89 |
# File 'lib/t2-server/exceptions.rb', line 87 def method @method end |
#path ⇒ Object (readonly)
The path of the URI that returned this error.
90 91 92 |
# File 'lib/t2-server/exceptions.rb', line 90 def path @path end |