Class: MinatoRubyApiClient::ApiError
- Inherits:
-
MinatoErrorHandler::Errors::ExternalError
- Object
- MinatoErrorHandler::Errors::ExternalError
- MinatoRubyApiClient::ApiError
- Defined in:
- lib/minato_ruby_api_client/api_error.rb
Instance Attribute Summary collapse
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
- #caused_by ⇒ Object
- #code ⇒ Object
- #details ⇒ Object
-
#initialize(res: nil, req: nil, status_code: 500) ⇒ ApiError
constructor
A new instance of ApiError.
- #message ⇒ Object
- #upstream_error? ⇒ Boolean
Constructor Details
#initialize(res: nil, req: nil, status_code: 500) ⇒ ApiError
Returns a new instance of ApiError.
8 9 10 11 12 13 14 15 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 8 def initialize(res: nil, req: nil, status_code: 500) super(req: req, res: res) @upstream_error = nil @status_code = status_code extracted_error, extracted_status = extract_upstream_error(res) @upstream_error = extracted_error @status_code = extracted_status || status_code end |
Instance Attribute Details
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
6 7 8 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 6 def status_code @status_code end |
Instance Method Details
#caused_by ⇒ Object
29 30 31 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 29 def caused_by upstream_field("caused_by") || super end |
#code ⇒ Object
21 22 23 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 21 def code upstream_field("code") || super end |
#details ⇒ Object
25 26 27 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 25 def details upstream_field("details") || super end |
#message ⇒ Object
17 18 19 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 17 def upstream_field("message") || "An error occurred while communicating with the API." end |
#upstream_error? ⇒ Boolean
33 34 35 |
# File 'lib/minato_ruby_api_client/api_error.rb', line 33 def upstream_error? !@upstream_error.nil? && !@upstream_error.empty? end |