Exception: Usps::Imis::Errors::ResponseError
- Inherits:
-
Usps::Imis::Error
- Object
- StandardError
- Usps::Imis::Error
- Usps::Imis::Errors::ResponseError
- Defined in:
- lib/usps/imis/errors/response_error.rb
Overview
Exception raised due to receiving an error response from the API
Instance Attribute Summary collapse
-
#metadata ⇒ Object
- Hash
-
Additional call-specific metadata to pass through to Bugsnag.
-
#response ⇒ Object
readonly
- Net::HTTPResponse
-
The response received from the API.
Class Method Summary collapse
-
.from(response) ⇒ Object
Create a new instance of
ResponseErrorfrom an API response.
Instance Method Summary collapse
-
#bugsnag_meta_data ⇒ Hash
Additional metadata to include in Bugsnag reports.
-
#initialize(response, metadata = {}) ⇒ ResponseError
constructor
Create a new instance of
ResponseError. -
#message ⇒ String
Auto-formatted exception message, based on the provided API response.
Constructor Details
#initialize(response, metadata = {}) ⇒ ResponseError
Create a new instance of ResponseError
28 29 30 31 |
# File 'lib/usps/imis/errors/response_error.rb', line 28 def initialize(response, = {}) @response = response super(, ) end |
Instance Attribute Details
#metadata ⇒ Object
- Hash
-
Additional call-specific metadata to pass through to Bugsnag
15 16 17 |
# File 'lib/usps/imis/errors/response_error.rb', line 15 def end |
#response ⇒ Object (readonly)
- Net::HTTPResponse
-
The response received from the API
11 12 13 |
# File 'lib/usps/imis/errors/response_error.rb', line 11 def response @response end |
Class Method Details
.from(response) ⇒ Object
Create a new instance of ResponseError from an API response
21 |
# File 'lib/usps/imis/errors/response_error.rb', line 21 def self.from(response) = new(response) |
Instance Method Details
#bugsnag_meta_data ⇒ Hash
Additional metadata to include in Bugsnag reports
Can include fields at the top level, which will be shows on the custom tab
Can include fields nested under a top-level key, which will be shown on a tab with the top-level key as its name
42 43 44 |
# File 'lib/usps/imis/errors/response_error.rb', line 42 def .tap { it[:api].merge!() } end |
#message ⇒ String
Auto-formatted exception message, based on the provided API response
50 51 52 53 54 55 56 |
# File 'lib/usps/imis/errors/response_error.rb', line 50 def [ "#{self.class.name}: [#{status.to_s.upcase}] The iMIS API returned an error.", (.inspect if != {}), body ].compact.join("\n") end |