Exception: Showroom::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/showroom/core/error.rb

Overview

Raised for HTTP responses with status >= 400.

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, body: nil, headers: {}) ⇒ ResponseError

Returns a new instance of ResponseError.

Parameters:

  • message (String) (defaults to: nil)

    error message

  • status (Integer) (defaults to: nil)

    HTTP status code

  • body (String, nil) (defaults to: nil)

    raw response body

  • headers (Hash) (defaults to: {})

    response headers



28
29
30
31
32
33
# File 'lib/showroom/core/error.rb', line 28

def initialize(message = nil, status: nil, body: nil, headers: {})
  super(message || "HTTP #{status}")
  @status  = status
  @body    = body
  @headers = headers
end

Instance Attribute Details

#bodyString? (readonly)

raw response body

Returns:

  • (String, nil)

    the current value of body



21
22
23
# File 'lib/showroom/core/error.rb', line 21

def body
  @body
end

#headersHash (readonly)

response headers

Returns:

  • (Hash)

    the current value of headers



21
22
23
# File 'lib/showroom/core/error.rb', line 21

def headers
  @headers
end

#statusInteger (readonly)

HTTP status code

Returns:

  • (Integer)

    the current value of status



21
22
23
# File 'lib/showroom/core/error.rb', line 21

def status
  @status
end