# google-cloud-errors - Class Google::Cloud::Error (v1.6.0)

1.6.0 (latest) 1.5.0 1.4.0 1.3.1 1.2.0 Reference documentation and code samples for the google-cloud-errors class Google::Cloud::Error.

Base google-cloud exception class.

## Inherits

- StandardError

## Methods

### #body

    def body() -> Object, nil

Returns the value of `body` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over HTTP/REST.
**Returns**

- (Object, nil)

### #code

    def code() -> Object, nil

Returns the value of `code` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Object, nil)

### #details

    def details() -> Object, nil

Returns the value of `details` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Object, nil)

### #domain

    def domain() -> Object, nil

Returns the value of `domain` from the `::Google::Rpc::ErrorInfo`
object, if it exists in the `status_details` array.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Object, nil)

### #error_info

    def error_info() -> ::Google::Rpc::ErrorInfo, nil

Returns the `::Google::Rpc::ErrorInfo` object present in the `status_details`
or `details` array, given that the following is true:

- either `status_details` or `details` exists and is an array
- there is exactly one `::Google::Rpc::ErrorInfo` object in that array. Looks in `status_details` first, then in `details`.
**Returns**

- (::Google::Rpc::ErrorInfo, nil)

### #error_metadata

    def error_metadata() -> Hash, nil

Returns the value of `metadata` from the `::Google::Rpc::ErrorInfo`
object, if it exists in the `status_details` array.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Hash, nil)

### #header

    def header() -> Object, nil

Returns the value of `header` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over HTTP/REST.
**Returns**

- (Object, nil)

### #initialize

    def initialize(msg = nil) -> Error

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

- **msg** (String, nil) --- an error message
**Returns**

- ([Error](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-errors/latest/Google-Cloud-Error)) --- a new instance of Error

### #metadata

    def metadata() -> Object, nil

Returns the value of `metadata` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Object, nil)

### #reason

    def reason() -> Object, nil

Returns the value of `reason` from the `::Google::Rpc::ErrorInfo`
object, if it exists in the `status_details` array.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Object, nil)

### #status_code

    def status_code() -> Object, nil

Returns the value of `status_code` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over HTTP/REST.
**Returns**

- (Object, nil)

### #status_details

    def status_details() -> Object, nil

Returns the value of `status_details` from the underlying cause error
object, if both are present. Otherwise returns `nil`.


<br />

This is typically present on errors originating from calls to an API
over gRPC.
**Returns**

- (Object, nil)