# Class: TRPCClientError<TRouterOrProcedure>

> 

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:121

The error a client call throws, whether the server sent an error or the
request failed.

## See

https://trpc.io/docs/client/vanilla/error-handling

## Extends

- `Error`

## Type Parameters

| Type Parameter |
| ------ |
| `TRouterOrProcedure` *extends* `InferrableClientTypes` |

## Implements

- [`TRPCClientErrorBase`](https://trpc.io/docs/typedoc/react-query/index/interfaces/TRPCClientErrorBase.md)\<`inferErrorShape`\<`TRouterOrProcedure`\>\>

## Constructors

### new TRPCClientError()

> **new TRPCClientError**\<`TRouterOrProcedure`\>(`message`, `opts`?): [`TRPCClientError`](https://trpc.io/docs/typedoc/react-query/index/classes/TRPCClientError.md)\<`TRouterOrProcedure`\>

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:134

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `message` | `string` |
| `opts`? | \{ `cause`: `Error`; `meta`: `Record`\<`string`, `unknown`\>; `result`: `Maybe`\<`TRPCErrorResponse`\<`inferErrorShape`\<`TRouterOrProcedure`\>\>\>; \} |
| `opts.cause`? | `Error` |
| `opts.meta`? | `Record`\<`string`, `unknown`\> |
| `opts.result`? | `Maybe`\<`TRPCErrorResponse`\<`inferErrorShape`\<`TRouterOrProcedure`\>\>\> |

#### Returns

[`TRPCClientError`](https://trpc.io/docs/typedoc/react-query/index/classes/TRPCClientError.md)\<`TRouterOrProcedure`\>

#### Overrides

`Error.constructor`

## Properties

### cause

> `readonly` **cause**: `undefined` \| `Error`

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:123

The error this one wraps, such as a network error.

#### Overrides

`Error.cause`

***

### data

> `readonly` **data**: `Maybe`\<`inferErrorShape`\<`TRouterOrProcedure`\>\[`"data"`\]\>

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:127

The shape's `data`, such as the tRPC code and HTTP status.

#### Implementation of

[`TRPCClientErrorBase`](https://trpc.io/docs/typedoc/react-query/index/interfaces/TRPCClientErrorBase.md).[`data`](https://trpc.io/docs/typedoc/react-query/index/interfaces/TRPCClientErrorBase.md#data)

***

### meta

> **meta**: `undefined` \| `Record`\<`string`, `unknown`\>

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:133

More about the error, if any. HTTP errors may have the `response` and
its `responseJSON`; a failed fetch or unparsable response may have
neither.

***

### shape

> `readonly` **shape**: `Maybe`\<`inferErrorShape`\<`TRouterOrProcedure`\>\>

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:125

The error as the server's error formatter shaped it, if it came from the server.

#### Implementation of

[`TRPCClientErrorBase`](https://trpc.io/docs/typedoc/react-query/index/interfaces/TRPCClientErrorBase.md).[`shape`](https://trpc.io/docs/typedoc/react-query/index/interfaces/TRPCClientErrorBase.md#shape)

## Methods

### from()

> `static` **from**\<`TRouterOrProcedure`\>(`_cause`, `opts`?): [`TRPCClientError`](https://trpc.io/docs/typedoc/react-query/index/classes/TRPCClientError.md)\<`TRouterOrProcedure`\>

Defined in: packages/client/dist/types-DO-GCB2q.d.mts:143

Turns an error response, an `Error` or another object into a
`TRPCClientError`. A `TRPCClientError` is returned as it is.

#### Type Parameters

| Type Parameter |
| ------ |
| `TRouterOrProcedure` *extends* `InferrableClientTypes` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `_cause` | `object` \| `Error` \| `TRPCErrorResponse`\<`any`\> |
| `opts`? | \{ `cause`: `Error`; `meta`: `Record`\<`string`, `unknown`\>; \} |
| `opts.cause`? | `Error` |
| `opts.meta`? | `Record`\<`string`, `unknown`\> |

#### Returns

[`TRPCClientError`](https://trpc.io/docs/typedoc/react-query/index/classes/TRPCClientError.md)\<`TRouterOrProcedure`\>
