<!--
 ⚠️  AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 This file is automatically generated by scripts/docs-generator.js
 To make changes, edit the source TypeScript files or update the generator script
-->

[agents](../../) / [Exports](../modules) / ErrorUtils

# Class: ErrorUtils

Error utility functions

## Table of contents

### Constructors

- [constructor](ErrorUtils#constructor)

### Methods

- [isRecoverable](ErrorUtils#isrecoverable)
- [getErrorCode](ErrorUtils#geterrorcode)
- [fromUnknown](ErrorUtils#fromunknown)
- [wrapProviderError](ErrorUtils#wrapprovidererror)

## Constructors

### constructor

• **new ErrorUtils**(): [`ErrorUtils`](ErrorUtils)

#### Returns

[`ErrorUtils`](ErrorUtils)

## Methods

### isRecoverable

▸ **isRecoverable**(`error`): `boolean`

Check if error is recoverable

#### Parameters

| Name    | Type    |
| :------ | :------ |
| `error` | `Error` |

#### Returns

`boolean`

#### Defined in

[packages/agents/src/utils/errors.ts:222](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/utils/errors.ts#L222)

---

### getErrorCode

▸ **getErrorCode**(`error`): `string`

Extract error code from any error

#### Parameters

| Name    | Type    |
| :------ | :------ |
| `error` | `Error` |

#### Returns

`string`

#### Defined in

[packages/agents/src/utils/errors.ts:232](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/utils/errors.ts#L232)

---

### fromUnknown

▸ **fromUnknown**(`error`, `defaultMessage?`): [`RobotaError`](RobotaError)

Create error from unknown value

#### Parameters

| Name             | Type                                                  | Default value                 |
| :--------------- | :---------------------------------------------------- | :---------------------------- |
| `error`          | [`ErrorExternalInput`](../modules#errorexternalinput) | `undefined`                   |
| `defaultMessage` | `string`                                              | `'An unknown error occurred'` |

#### Returns

[`RobotaError`](RobotaError)

#### Defined in

[packages/agents/src/utils/errors.ts:242](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/utils/errors.ts#L242)

---

### wrapProviderError

▸ **wrapProviderError**(`error`, `provider`, `operation`): [`ProviderError`](ProviderError)

Wrap external errors

#### Parameters

| Name        | Type                                                  |
| :---------- | :---------------------------------------------------- |
| `error`     | [`ErrorExternalInput`](../modules#errorexternalinput) |
| `provider`  | `string`                                              |
| `operation` | `string`                                              |

#### Returns

[`ProviderError`](ProviderError)

#### Defined in

[packages/agents/src/utils/errors.ts:258](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/utils/errors.ts#L258)
