Exception: Google::Cloud::Error

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

Overview

Base google-cloud exception class.

Instance Method Summary collapse

Constructor Details

#initialize(msg = nil) ⇒ Error

Construct a new Google::Cloud::Error object, optionally passing in a message.



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

def initialize msg = nil
  super
  @cause = $ERROR_INFO
end

Instance Method Details

#bodyObject?

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.

Returns:

  • (Object, nil)


63
64
65
66
# File 'lib/google/cloud/errors.rb', line 63

def body
  return nil unless cause && cause.respond_to?(:body)
  cause.body
end

#causeObject

The previous exception at the time this exception was raised. This is useful for wrapping exceptions and retaining the original exception information.



37
38
39
# File 'lib/google/cloud/errors.rb', line 37

define_method(:cause) do
  @cause
end

#codeObject?

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.

Returns:

  • (Object, nil)


89
90
91
92
# File 'lib/google/cloud/errors.rb', line 89

def code
  return nil unless cause && cause.respond_to?(:code)
  cause.code
end

#detailsObject?

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.

Returns:

  • (Object, nil)


102
103
104
105
# File 'lib/google/cloud/errors.rb', line 102

def details
  return nil unless cause && cause.respond_to?(:details)
  cause.details
end

#headerObject?

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.

Returns:

  • (Object, nil)


76
77
78
79
# File 'lib/google/cloud/errors.rb', line 76

def header
  return nil unless cause && cause.respond_to?(:header)
  cause.header
end

#metadataObject?

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.

Returns:

  • (Object, nil)


115
116
117
118
# File 'lib/google/cloud/errors.rb', line 115

def 
  return nil unless cause && cause.respond_to?(:metadata)
  cause.
end

#status_codeObject?

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.

Returns:

  • (Object, nil)


50
51
52
53
# File 'lib/google/cloud/errors.rb', line 50

def status_code
  return nil unless cause && cause.respond_to?(:status_code)
  cause.status_code
end

#status_detailsObject?

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.

Returns:

  • (Object, nil)


128
129
130
131
# File 'lib/google/cloud/errors.rb', line 128

def status_details
  return nil unless cause && cause.respond_to?(:status_details)
  cause.status_details
end