# Google API Core Client - Class ApiException (1.43.0)

1.43.0 (latest) 1.42.5 1.40.0 1.38.2 1.36.1 1.35.1 Reference documentation and code samples for the Google API Core Client class ApiException.

Represents an exception thrown during an RPC.

## Namespace

Google \\ ApiCore

## Methods

### __construct

ApiException constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `message` | `string` |
| `code` | `int` |
| `status` | `string|null` |
| `optionalArgs` | `array` { @type Exception\|null $previous @type array\|null $metadata @type string\|null $basicMessage } |
| `↳ previous` | `Exception|null` |
| `↳ metadata` | `array|null` |
| `↳ basicMessage` | `string|null` |
| `protobufErrors` | `array` |

### getStatus

### getReason

Returns the `reason` in ErrorInfo for an exception, or null if there is no ErrorInfo.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string|null` | $reason |

### getDomain

Returns the `domain` in ErrorInfo for an exception, or null if there is no ErrorInfo.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string|null` | $domain |

### getErrorInfoMetadata

Returns the `metadata` in ErrorInfo for an exception, or null if there is no ErrorInfo.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array|null` | $errorInfoMetadata |

### getErrorDetails

Returns the unserialized errors

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### getBasicMessage

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `null|string` |   |

### getMetadata

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### static::createFromStdClass

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `status` | `stdClass` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/ApiException` |   |

### static::createFromApiResponse

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `basicMessage` | `string` |
| `rpcCode` | `int` |
| `metadata` | `array|null` |
| `previous` | `Exception` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/ApiException` |   |

### static::createFromRestApiResponse

For REST-based responses, the metadata does not need to be decoded.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `basicMessage` | `string` |
| `rpcCode` | `int` |
| `metadata` | `array|null` |
| `previous` | `Exception` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/ApiException` |   |

### static::createFromRpcStatus

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `status` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Rpc.Status.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/ApiException` |   |

### static::createFromRequestException

Creates an ApiException from a GuzzleHttp RequestException.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `ex` | `GuzzleHttp\Exception\RequestException` |
| `isStream` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/ApiException` |   |