Exception: Blanket::Exception

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/blanket/exception.rb

Overview

The base class for all Blanket Exceptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ Blanket::Exception

Creates a new exception

Parameters:

  • response (HTTParty::Response) (defaults to: nil)

    the HTTP Response



59
60
61
# File 'lib/blanket/exception.rb', line 59

def initialize(response = nil)
  @response = response
end

Instance Attribute Details

#messageObject

Returns a formatted error message



74
75
76
# File 'lib/blanket/exception.rb', line 74

def message
  @message || self.class.name
end

#responseObject (readonly)

Attribute reader for the Exception http response



54
55
56
# File 'lib/blanket/exception.rb', line 54

def response
  @response
end

Instance Method Details

#bodyObject

Returns the HTTP response body



64
65
66
# File 'lib/blanket/exception.rb', line 64

def body
  @response.body.to_s if @response
end

#codeObject

Returns the HTTP status code



69
70
71
# File 'lib/blanket/exception.rb', line 69

def code
  @response.code.to_i if @response
end

#inspectObject Also known as: to_s

Returns a stringified error message



79
80
81
# File 'lib/blanket/exception.rb', line 79

def inspect
  "#{message}: #{body}"
end