Exception: Gapic::Rest::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Gapic::Rest::Error
- Defined in:
- lib/gapic/rest/error.rb
Overview
Gapic REST exception class
Instance Attribute Summary collapse
-
#status_code ⇒ Integer
readonly
The http status code for the error.
Class Method Summary collapse
-
.wrap_faraday_error(err) ⇒ Object
This creates a new error message wrapping the Faraday's one.
Instance Method Summary collapse
-
#initialize(message, status_code) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, status_code) ⇒ Error
Returns a new instance of Error.
28 29 30 31 |
# File 'lib/gapic/rest/error.rb', line 28 def initialize , status_code @status_code = status_code super end |
Instance Attribute Details
#status_code ⇒ Integer (readonly)
Returns the http status code for the error.
22 23 24 |
# File 'lib/gapic/rest/error.rb', line 22 def status_code @status_code end |
Class Method Details
.wrap_faraday_error(err) ⇒ Object
This creates a new error message wrapping the Faraday's one. Additionally it tries to parse and set a detailed message and an error code from from the Google Cloud's response body
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gapic/rest/error.rb', line 39 def wrap_faraday_error err = err. status_code = err.response_status if err.response_body msg, code = try_parse_from_body err.response_body = "An error has occurred when making a REST request: #{msg}" unless msg.nil? status_code = code unless code.nil? end Gapic::Rest::Error.new , status_code end |