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

# EmbedEditorError

> The error onLoadError and onProcessError receive and processImage and the commands reject with, and what each code means.

`EmbedEditorError` tells you what failed, by a `code`.

```ts theme={"dark"}
class EmbedEditorError<Code extends EmbedEditorErrorCode | EmbedEditorCommandErrorCode = EmbedEditorErrorCode> extends Error {
	code: Code;
	props: string[];
}
```

`onLoadError` and `onProcessError` receive one, and `processImage` and the [commands](https://docs.embededitor.com/api-reference/commands/overview.md) reject with one. Both entries export the class, so `instanceof` works with either.

`Code` is the codes it can hold: the editor's own (`EmbedEditorErrorCode`) unless said. A command rejects with one of the command's own codes (`EmbedEditorCommandErrorCode`) too.

## Fields

**code** `Code`

What failed. See [Codes](#codes).

**props** `string[]`

The props `INVALID_PROPS` names, a nested one by its path (`colors.accent`, `lang.texts.buttonSave`), or the paths `INVALID_COMMAND` names (`input.item`, or `command` for a command the handle doesn't have). Empty for any other code.

**cause** `unknown`

The error under it, when there is one. For an `INVALID_COMMAND` off the schema, the schema's own error, with every issue; none for an unknown command name or for an input the command can't take where the editor stands.

**message** `string`

The same as `code`.

**name** `string`

`'EmbedEditorError'`.

## Codes

| `code` | What happened |
| - | - |
| `INVALID_PROPS` | A prop (or a `processImage` option) the editor can't take. |
| `INVALID_STATE` | `state` is a saved state the editor can't read: a wrong version, a value out of range, more than 64 areas. |
| `LOAD_FAILED` | The image couldn't be fetched or read: a 404, a network or CORS failure, an `<img>` with no source, a closed ImageBitmap, an empty canvas. |
| `UNSUPPORTED_FORMAT` | The file isn't an image the editor reads: TIFF, text, a truncated file. |
| `WEBGL_UNAVAILABLE` | The browser can't run the editor: no WebGL 2, or a GPU that can't build the shaders a frame needs. |
| `MARK_FAILED` | A watermark or signature couldn't load (its image, or the letter of a text mark), or Save couldn't draw it. A fixed or required one keeps Save, Copy and Share off, and the banner over the toolbar offers Retry; a free one is left out of the file. `processImage` rejects with it for a fixed or required mark. |
| `EXPORT_FAILED` | Save (or `processImage`) couldn't make the file, the GPU's limits included. In the editor, the banner over the toolbar says so too. |

A command has three codes of its own, `EmbedEditorCommandErrorCode`:

| `code` | What happened |
| - | - |
| `INVALID_COMMAND`, off the schema | The input is off the command's schema, or `run` names a command the handle doesn't have. `props` names each invalid path, and `cause` holds the schema's own error (none for an unknown name). It rejects at once. |
| `INVALID_COMMAND`, can't be taken here | The input fits the schema, but not where the editor stands: an area no drag would draw, a key the annotation's kind doesn't take, a size off the watermark's layout. It rejects on the command's turn, `props` naming the paths, with no `cause`. |
| `NOT_AVAILABLE` | The tool is off by a prop or isn't in the edition, the editor has no close (`editor.close` with no `onClose`), or the editor was destroyed, closed or left the page. Each command's page lists its own cases. |
| `NOT_FOUND` | No area at that index, no annotation with that id. |

## Where Each One Arrives

| Callback | Codes |
| - | - |
| `onLoadError` | `INVALID_PROPS`, `INVALID_STATE`, `LOAD_FAILED`, `UNSUPPORTED_FORMAT`, `WEBGL_UNAVAILABLE`, and `MARK_FAILED` when a mark can't load. The error screen shows it too. |
| `onProcessError` | `EXPORT_FAILED`, and `MARK_FAILED` when Save can't draw a fixed or required mark. |
| `processImage` | Rejects with `INVALID_PROPS` before anything loads, `LOAD_FAILED` or `UNSUPPORTED_FORMAT` for an image it can't read, `MARK_FAILED` for a fixed or required mark, or `EXPORT_FAILED` when it can't make the file. |
| A command | Rejects with `INVALID_COMMAND`, `NOT_AVAILABLE` or `NOT_FOUND`. `output.save`, `output.exportFile` and `read.screenshot` also reject with `EXPORT_FAILED` or `MARK_FAILED`, as Save. See [Commands](https://docs.embededitor.com/api-reference/commands/overview.md#errors). |

> [!NOTE]
>
> An error your own callback throws is not an `EmbedEditorError`. It is logged with `console.error` and never rethrown. If `onProcess` throws, Save shows it failed and `onProcessError` isn't called; `output.save` then rejects with `EXPORT_FAILED`, your error as its `cause`.

## Example

```ts errors.ts theme={"dark"}
import { EmbedEditorError, openEditor } from '@embededitor/full/react';

openEditor({
	onLoadError: (error: EmbedEditorError) => {
		if (error.code === 'INVALID_PROPS') {
			console.error('invalid props:', error.props.join(', '));
		}
	},
	src: '/photos/sunset.jpg'
});
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.