> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# isError

```ts theme={null}
function isError<K, T>(error, code): error is T
```

Returns true if the `error` matches an error thrown by quais that matches the error `code`.

In TypeScript environments, this can be used to check that `error` matches an quaisError type, which means the
expected properties will be set.

## Type parameters

| Type parameter                                                                          |
| :-------------------------------------------------------------------------------------- |
| `K` *extends* [`ErrorCode`](/sdk/content/type-aliases/ErrorCode)                        |
| `T` *extends*                                                                           |
| \| [`UnknownError`](/sdk/content/interfaces/UnknownError)                               |
| \| [`InvalidArgumentError`](/sdk/content/interfaces/InvalidArgumentError)               |
| \| [`BadDataError`](/sdk/content/interfaces/BadDataError)                               |
| \| [`NotImplementedError`](/sdk/content/interfaces/NotImplementedError)                 |
| \| [`UnsupportedOperationError`](/sdk/content/interfaces/UnsupportedOperationError)     |
| \| [`NetworkError`](/sdk/content/interfaces/NetworkError)                               |
| \| [`ServerError`](/sdk/content/interfaces/ServerError)                                 |
| \| [`TimeoutError`](/sdk/content/interfaces/TimeoutError)                               |
| \| [`CancelledError`](/sdk/content/interfaces/CancelledError)                           |
| \| [`BufferOverrunError`](/sdk/content/interfaces/BufferOverrunError)                   |
| \| [`NumericFaultError`](/sdk/content/interfaces/NumericFaultError)                     |
| \| [`MissingArgumentError`](/sdk/content/interfaces/MissingArgumentError)               |
| \| [`UnexpectedArgumentError`](/sdk/content/interfaces/UnexpectedArgumentError)         |
| \| [`CallExceptionError`](/sdk/content/interfaces/CallExceptionError)                   |
| \| [`InsufficientFundsError`](/sdk/content/interfaces/InsufficientFundsError)           |
| \| [`NonceExpiredError`](/sdk/content/interfaces/NonceExpiredError)                     |
| \| [`ReplacementUnderpricedError`](/sdk/content/interfaces/ReplacementUnderpricedError) |
| \| [`TransactionReplacedError`](/sdk/content/interfaces/TransactionReplacedError)       |
| \| `TransactionNotFoundError`                                                           |
| \| `TransactionAlreadyKnown`                                                            |
| \| [`ActionRejectedError`](/sdk/content/interfaces/ActionRejectedError)                 |
| \| `ProviderFailedToInitializeError`                                                    |

## Parameters

| Parameter | Type  |
| :-------- | :---- |
| `error`   | `any` |
| `code`    | `K`   |

## Returns

`error is T`

## Example

```ts theme={null}
try {
    // code....
} catch (e) {
    if (isError(e, 'CALL_EXCEPTION')) {
        // The Type Guard has validated this object
        console.log(e.data);
    }
}
```

## See

[ErrorCodes](api:ErrorCode)

## Source

[utils/errors.ts:664](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/errors.ts#L664)
