# Error codes

> Every document engine error code, such as SAVE_CONFLICT, MISSING_ASSETS and UNSAVED_CHANGES, with when it happens and how to handle it in your editor.

Source: https://fabricjs-document-engine.jscrate.dev/docs/api/error-codes
Last updated: 2026-09-28

Every failure is a `DocumentEngineError` with a stable `code`. Document engine error codes never change within 1.x, so switch on the code and never on the message text.

```ts
import { isDocumentEngineError } from "fabricjs-document-engine";

try {
  await engine.load(id);
} catch (error) {
  if (isDocumentEngineError(error) && error.code === "UNSAVED_CHANGES") {
    await engine.save();
    await engine.load(id);
  }
}
```

Besides `code`, an error can carry `issues`, `unknownTypes`, `missingAssets`, `missingFonts`, `problems`, `migrationFrom`, `retryable` and `cause`.

## All document engine error codes

| Code                     | When                                                                                |
| ------------------------ | ----------------------------------------------------------------------------------- |
| `INVALID_DOCUMENT`       | The document shape is wrong, or the imported text is not JSON                       |
| `UNSAFE_DOCUMENT`        | An unsafe image address, too many objects, or nesting too deep                      |
| `UNSUPPORTED_SCHEMA`     | Written by a newer major version of this package                                    |
| `UNKNOWN_OBJECT_TYPE`    | A custom class is not registered                                                    |
| `INVALID_CUSTOM_OBJECT`  | A registered class has no static `type`, or is not a Fabric.js class                |
| `MIGRATION_FAILED`       | An older document could not be upgraded                                             |
| `LOAD_ABORTED`           | A newer load, or `destroy`, stopped this load                                       |
| `LOAD_FAILED`            | Fabric.js or storage failed to load                                                 |
| `MISSING_ASSETS`         | Images could not be loaded                                                          |
| `MISSING_FONTS`          | Fonts are unavailable and `requireFonts` is on                                      |
| `ASSET_UPLOAD_FAILED`    | The `upload` handler failed                                                         |
| `UNSAVED_CHANGES`        | Opening another document would discard unsaved changes                              |
| `STORAGE_MISSING`        | `load`, `save` or autosave was used without storage                                 |
| `SAVE_FAILED`            | Storage refused after all retries                                                   |
| `SAVE_CONFLICT`          | Another tab or device saved first                                                   |
| `SAVE_CANCELLED`         | A save was dropped because another document was opened, or the engine was destroyed |
| `DOCUMENT_NOT_FOUND`     | A built-in adapter has no such document                                             |
| `HISTORY_FAILED`         | Undo or redo could not rebuild an object                                            |
| `RECOVERY_MISSING`       | Recovery is not configured                                                          |
| `RECOVERY_NOT_FOUND`     | There is no recovery copy                                                           |
| `RECOVERY_FAILED`        | A recovery copy could not be written                                                |
| `VERSIONS_UNSUPPORTED`   | Storage has no version methods                                                      |
| `VERSION_NOT_FOUND`      | There is no such version                                                            |
| `VERSION_FAILED`         | An automatic version failed                                                         |
| `INVALID_EXPORT_OPTIONS` | The export options are not valid                                                    |
| `EXPORT_BLOCKED`         | An image or font would break the export. See `error.problems`                       |
| `EXPORT_ABORTED`         | The export was cancelled                                                            |
| `EXPORT_FAILED`          | Rendering failed                                                                    |
| `ENGINE_DESTROYED`       | The engine was used after `destroy()`                                               |

## The ones that need UI

Most document engine error codes are logged and forgotten. These need the user to decide, so give them a dialog: `SAVE_CONFLICT` ([save conflicts](https://fabricjs-document-engine.jscrate.dev/docs/guides/save-conflicts)), `MISSING_ASSETS` ([images and fonts](https://fabricjs-document-engine.jscrate.dev/docs/guides/assets-and-fonts)) and `UNSAVED_CHANGES`. A full handler is in the [production checklist](https://fabricjs-document-engine.jscrate.dev/docs/production/production-checklist).
