Exception: Litmus::Infrastructure::ServerException

Inherits:
GenericError
  • Object
show all
Defined in:
lib/litmus/infrastructure/exceptions.rb

Overview

Raised when a 500 response code has been received.

Attributes

  • response - The Response from the Litmus Infrastructure API

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

included

Constructor Details

#initialize(response, params = nil) ⇒ ServerException

:nodoc:



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/litmus/infrastructure/exceptions.rb', line 43

def initialize(response, params = nil) #:nodoc:
  @response  = response
  status     = response.status
  headers    = response.http_header
  req_method = headers.request_method
  req_uri    = headers.request_uri
  error      = headers.reason_phrase

  message = "#{req_method} #{req_uri} failed with #{status} (#{error})"
  message += "\n\nResponse: #{response.body}"
  message += "\n\nRequest body: #{params.to_json}" if params.is_a?(Hash)
  super message
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



41
42
43
# File 'lib/litmus/infrastructure/exceptions.rb', line 41

def response
  @response
end