Exception: Google::Cloud::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Google::Cloud::Error
- Defined in:
- lib/google/cloud/errors.rb
Overview
Base google-cloud exception class.
Direct Known Subclasses
AbortedError, AlreadyExistsError, CanceledError, DataLossError, DeadlineExceededError, FailedPreconditionError, InternalError, InvalidArgumentError, NotFoundError, OutOfRangeError, PermissionDeniedError, ResourceExhaustedError, UnauthenticatedError, UnavailableError, UnimplementedError, UnknownError
Instance Method Summary collapse
-
#body ⇒ Object?
Returns the value of
body
from the underlying cause error object, if both are present. -
#code ⇒ Object?
Returns the value of
code
from the underlying cause error object, if both are present. -
#details ⇒ Object?
Returns the value of
details
from the underlying cause error object, if both are present. -
#domain ⇒ Object?
Returns the value of
domain
from the::Google::Rpc::ErrorInfo
object, if it exists in thestatus_details
array. -
#error_info ⇒ ::Google::Rpc::ErrorInfo?
Returns the
::Google::Rpc::ErrorInfo
object present in thestatus_details
ordetails
array, given that the following is true: * eitherstatus_details
ordetails
exists and is an array * there is exactly one::Google::Rpc::ErrorInfo
object in that array. -
#error_metadata ⇒ Hash?
Returns the value of
metadata
from the::Google::Rpc::ErrorInfo
object, if it exists in thestatus_details
array. -
#header ⇒ Object?
Returns the value of
header
from the underlying cause error object, if both are present. -
#initialize(msg = nil) ⇒ Error
constructor
Construct a new Google::Cloud::Error object, optionally passing in a message.
-
#metadata ⇒ Object?
Returns the value of
metadata
from the underlying cause error object, if both are present. -
#reason ⇒ Object?
Returns the value of
reason
from the::Google::Rpc::ErrorInfo
object, if it exists in thestatus_details
array. -
#status_code ⇒ Object?
Returns the value of
status_code
from the underlying cause error object, if both are present. -
#status_details ⇒ Object?
Returns the value of
status_details
from the underlying cause error object, if both are present.
Constructor Details
#initialize(msg = nil) ⇒ Error
Construct a new Google::Cloud::Error object, optionally passing in a message.
28 29 30 |
# File 'lib/google/cloud/errors.rb', line 28 def initialize msg = nil super end |
Instance Method Details
#body ⇒ Object?
Returns the value of body
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over HTTP/REST.
53 54 55 56 |
# File 'lib/google/cloud/errors.rb', line 53 def body return nil unless cause.respond_to? :body cause.body end |
#code ⇒ Object?
Returns the value of code
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over gRPC.
79 80 81 82 |
# File 'lib/google/cloud/errors.rb', line 79 def code return nil unless cause.respond_to? :code cause.code end |
#details ⇒ Object?
Returns the value of details
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over gRPC.
92 93 94 95 |
# File 'lib/google/cloud/errors.rb', line 92 def details return nil unless cause.respond_to? :details cause.details end |
#domain ⇒ Object?
Returns the value of domain
from the ::Google::Rpc::ErrorInfo
object, if it exists in the status_details
array.
This is typically present on errors originating from calls to an API over gRPC.
154 155 156 157 |
# File 'lib/google/cloud/errors.rb', line 154 def domain return nil unless error_info.respond_to? :domain error_info.domain end |
#error_info ⇒ ::Google::Rpc::ErrorInfo?
Returns the ::Google::Rpc::ErrorInfo
object present in the status_details
or details
array, given that the following is true:
- either
status_details
ordetails
exists and is an array - there is exactly one
::Google::Rpc::ErrorInfo
object in that array. Looks instatus_details
first, then indetails
.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/google/cloud/errors.rb', line 131 def error_info @error_info ||= begin check_property = lambda do |prop| if prop.is_a? Array error_infos = prop.find_all { |status| status.is_a? ::Google::Rpc::ErrorInfo } if error_infos.length == 1 error_infos[0] end end end check_property.call(status_details) || check_property.call(details) end end |
#error_metadata ⇒ Hash?
Returns the value of metadata
from the ::Google::Rpc::ErrorInfo
object, if it exists in the status_details
array.
This is typically present on errors originating from calls to an API over gRPC.
180 181 182 183 |
# File 'lib/google/cloud/errors.rb', line 180 def return nil unless error_info.respond_to? :metadata error_info..to_h end |
#header ⇒ Object?
Returns the value of header
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over HTTP/REST.
66 67 68 69 |
# File 'lib/google/cloud/errors.rb', line 66 def header return nil unless cause.respond_to? :header cause.header end |
#metadata ⇒ Object?
Returns the value of metadata
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over gRPC.
105 106 107 108 |
# File 'lib/google/cloud/errors.rb', line 105 def return nil unless cause.respond_to? :metadata cause. end |
#reason ⇒ Object?
Returns the value of reason
from the ::Google::Rpc::ErrorInfo
object, if it exists in the status_details
array.
This is typically present on errors originating from calls to an API over gRPC.
167 168 169 170 |
# File 'lib/google/cloud/errors.rb', line 167 def reason return nil unless error_info.respond_to? :reason error_info.reason end |
#status_code ⇒ Object?
Returns the value of status_code
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over HTTP/REST.
40 41 42 43 |
# File 'lib/google/cloud/errors.rb', line 40 def status_code return nil unless cause.respond_to? :status_code cause.status_code end |
#status_details ⇒ Object?
Returns the value of status_details
from the underlying cause error
object, if both are present. Otherwise returns nil
.
This is typically present on errors originating from calls to an API over gRPC.
118 119 120 121 |
# File 'lib/google/cloud/errors.rb', line 118 def status_details return nil unless cause.respond_to? :status_details cause.status_details end |