Exception: Gapic::Rest::Error
- Inherits:
-
Common::Error
- Object
- StandardError
- Common::Error
- Gapic::Rest::Error
- Defined in:
- lib/gapic/rest/error.rb
Overview
Gapic REST exception class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#details ⇒ Object?
readonly
The details as parsed from the response body.
-
#headers ⇒ Object?
(also: #header)
readonly
The headers of the REST error.
-
#status ⇒ Object?
readonly
The text representation of status as parsed from the response body.
-
#status_code ⇒ Integer?
readonly
The http status code for the error.
Class Method Summary collapse
-
.wrap_faraday_error(err) ⇒ Gapic::Rest::Error
This creates a new error message wrapping the Faraday's one.
Instance Method Summary collapse
-
#initialize(message, status_code, status: nil, details: nil, headers: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, status_code, status: nil, details: nil, headers: nil) ⇒ Error
Returns a new instance of Error.
40 41 42 43 44 45 46 |
# File 'lib/gapic/rest/error.rb', line 40 def initialize , status_code, status: nil, details: nil, headers: nil super @status_code = status_code @status = status @details = details @headers = headers end |
Instance Attribute Details
#details ⇒ Object? (readonly)
Returns the details as parsed from the response body.
27 28 29 |
# File 'lib/gapic/rest/error.rb', line 27 def details @details end |
#headers ⇒ Object? (readonly) Also known as: header
Returns the headers of the REST error.
29 30 31 |
# File 'lib/gapic/rest/error.rb', line 29 def headers @headers end |
#status ⇒ Object? (readonly)
Returns the text representation of status as parsed from the response body.
25 26 27 |
# File 'lib/gapic/rest/error.rb', line 25 def status @status end |
#status_code ⇒ Integer? (readonly)
Returns the http status code for the error.
23 24 25 |
# File 'lib/gapic/rest/error.rb', line 23 def status_code @status_code end |
Class Method Details
.wrap_faraday_error(err) ⇒ Gapic::Rest::Error
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
57 58 59 60 |
# File 'lib/gapic/rest/error.rb', line 57 def wrap_faraday_error err , status_code, status, details, headers = parse_faraday_error err Gapic::Rest::Error.new , status_code, status: status, details: details, headers: headers end |