Exception: Google::Cloud::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Google::Cloud::Error
show all
- 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
Class Method Summary
collapse
Class Method Details
.from_error(error) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/google/cloud/errors.rb', line 22
def self.from_error error
klass = if error.respond_to? :code
grpc_error_class_for error.code
elsif error.respond_to? :status_code
gapi_error_class_for error.status_code
else
self
end
klass.new error.message
end
|
.gapi_error_class_for(http_status_code) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/google/cloud/errors.rb', line 46
def self.gapi_error_class_for http_status_code
{ 400 => InvalidArgumentError, 401 => UnauthenticatedError,
403 => PermissionDeniedError,
404 => NotFoundError,
409 => AlreadyExistsError, 429 => ResourceExhaustedError,
499 => CanceledError,
500 => InternalError, 501 => UnimplementedError,
503 => UnavailableError,
504 => DeadlineExceededError
}[http_status_code] || self
end
|
.grpc_error_class_for(grpc_error_code) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/google/cloud/errors.rb', line 34
def self.grpc_error_class_for grpc_error_code
[self, CanceledError, UnknownError, InvalidArgumentError,
DeadlineExceededError, NotFoundError, AlreadyExistsError,
PermissionDeniedError, ResourceExhaustedError, FailedPreconditionError,
AbortedError, OutOfRangeError, UnimplementedError, InternalError,
UnavailableError, DataLossError, UnauthenticatedError
][grpc_error_code] || self
end
|