Class: FreightKit::HTTPError
- Defined in:
- lib/freight_kit/errors/http_error.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(body:, code:) ⇒ HTTPError
constructor
A new instance of HTTPError.
- #message ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(body:, code:) ⇒ HTTPError
Returns a new instance of HTTPError.
7 8 9 10 11 12 |
# File 'lib/freight_kit/errors/http_error.rb', line 7 def initialize(body:, code:) @body = body @code = code super() end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/freight_kit/errors/http_error.rb', line 5 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/freight_kit/errors/http_error.rb', line 5 def code @code end |
Instance Method Details
#message ⇒ Object
14 15 16 17 18 19 |
# File 'lib/freight_kit/errors/http_error.rb', line 14 def @message ||= ''.tap do |builder| builder << "HTTP #{@code}" builder << ":\n#{@body}" if @body.present? end end |
#to_hash ⇒ Object
21 22 23 |
# File 'lib/freight_kit/errors/http_error.rb', line 21 def to_hash @to_hash ||= { code: @http.code, headers: @http.headers, body: @http.body } end |