Exception: T2Server::UnexpectedServerResponse

Inherits:
T2ServerError
  • Object
show all
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

Instance Method Summary collapse

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.



106
107
108
109
110
111
112
113
114
115
# File 'lib/t2-server/exceptions.rb', line 106

def initialize(method, path, response)
  @method = method
  @path = path
  @code = response.code
  @body = response.body.to_s
  @body = @body.empty? ? "<none>" : "#{response.body}"
  message = "Unexpected server response:\n  Method: #{@method}\n  Path: "\
    "#{@path}\n  Code: #{@code}\n  Body: #{@body}"
  super message
end

Instance Attribute Details

#bodyObject (readonly)

The response body of this error. If the server did not supply one then this will be “<none>”.



100
101
102
# File 'lib/t2-server/exceptions.rb', line 100

def body
  @body
end

#codeObject (readonly)

The HTTP error code of this error.



96
97
98
# File 'lib/t2-server/exceptions.rb', line 96

def code
  @code
end

#methodObject (readonly)

The method that was called to produce this error.



90
91
92
# File 'lib/t2-server/exceptions.rb', line 90

def method
  @method
end

#pathObject (readonly)

The path of the URI that returned this error.



93
94
95
# File 'lib/t2-server/exceptions.rb', line 93

def path
  @path
end