Exception: Solace::Errors::HTTPError
- Inherits:
-
StandardError
- Object
- StandardError
- Solace::Errors::HTTPError
- Defined in:
- lib/solace/errors/http_error.rb
Overview
Non-2xx HTTP or low-level network issues
Instance Attribute Summary collapse
- #body ⇒ Object readonly
- #code ⇒ Object readonly
Class Method Summary collapse
-
.format_response(response) ⇒ Solace::Errors::HTTPError
Formats a response to an error.
-
.format_timeout_error(error) ⇒ Solace::Errors::HTTPError
Formats timeout errors.
-
.format_transport_error(error) ⇒ Solace::Errors::HTTPError
Formats transport errors.
Instance Method Summary collapse
-
#initialize(message, code:, body: nil) ⇒ HTTPError
constructor
A new instance of HTTPError.
Constructor Details
#initialize(message, code:, body: nil) ⇒ HTTPError
Returns a new instance of HTTPError.
12 13 14 15 16 |
# File 'lib/solace/errors/http_error.rb', line 12 def initialize(, code:, body: nil) super() @code = code @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
7 8 9 |
# File 'lib/solace/errors/http_error.rb', line 7 def body @body end |
#code ⇒ Object (readonly)
7 8 9 |
# File 'lib/solace/errors/http_error.rb', line 7 def code @code end |
Class Method Details
.format_response(response) ⇒ Solace::Errors::HTTPError
Formats a response to an error
22 23 24 |
# File 'lib/solace/errors/http_error.rb', line 22 def self.format_response(response) new("HTTP error: #{response.message}", code: response.code.to_i, body: response.body) end |
.format_timeout_error(error) ⇒ Solace::Errors::HTTPError
Formats timeout errors
38 39 40 |
# File 'lib/solace/errors/http_error.rb', line 38 def self.format_timeout_error(error) new("HTTP timeout: #{error.class}", code: 408) end |
.format_transport_error(error) ⇒ Solace::Errors::HTTPError
Formats transport errors
30 31 32 |
# File 'lib/solace/errors/http_error.rb', line 30 def self.format_transport_error(error) new("HTTP transport error: #{error.message}", code: 0) end |