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?
(also: #status_details)
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.
45 46 47 48 49 50 51 |
# File 'lib/gapic/rest/error.rb', line 45 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) Also known as: status_details
Returns the details as parsed from the response body.
30 31 32 |
# File 'lib/gapic/rest/error.rb', line 30 def details @details end |
#headers ⇒ Object? (readonly) Also known as: header
Returns the headers of the REST error.
34 35 36 |
# File 'lib/gapic/rest/error.rb', line 34 def headers @headers end |
#status ⇒ Object? (readonly)
Returns the text representation of status as parsed from the response body.
28 29 30 |
# File 'lib/gapic/rest/error.rb', line 28 def status @status end |
#status_code ⇒ Integer? (readonly)
Returns the http status code for the error.
26 27 28 |
# File 'lib/gapic/rest/error.rb', line 26 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
62 63 64 65 |
# File 'lib/gapic/rest/error.rb', line 62 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 |