Exception: Gcloud::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/gcloud/errors.rb

Overview

Base Gcloud exception class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, error = nil) ⇒ Error

Create a new error object.



26
27
28
29
# File 'lib/gcloud/errors.rb', line 26

def initialize message = nil, error = nil
  super message
  @inner = error
end

Instance Attribute Details

#innerObject (readonly)

The inner error object.



22
23
24
# File 'lib/gcloud/errors.rb', line 22

def inner
  @inner
end

Class Method Details

.from_error(error) ⇒ Object



32
33
34
# File 'lib/gcloud/errors.rb', line 32

def self.from_error error
  klass_for(error).new error.message, error
end

.klass_for(error) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gcloud/errors.rb', line 37

def self.klass_for error
  return self.class unless error.is_a? GRPC::BadStatus
  # The gRPC status code 0 is for a successful response.
  # So there is no error subclass for a 0 status code, use current class.
  [self.class, CanceledError, UnknownError, InvalidArgumentError,
   DeadlineExceededError, NotFoundError, AlreadyExistsError,
   PermissionDeniedError, ResourceExhaustedError, FailedPreconditionError,
   AbortedError, OutOfRangeError, UnimplementedError, InternalError,
   UnavailableError, DataLossError, UnauthenticatedError
  ][error.code] || self.class
end