Skip to content

Errors ​

The package exports typed errors for catalog validation and runtime loading. All of them extend Error and set name to the class name.

Catalog and persistence ​

ErrorThrown when
AssetAlreadyExistsErrorAssetCatalog.add() receives an existing ID
AssetNotFoundErrorA catalog operation cannot find the requested ID
AssetKindMismatchErrorA reference's expected kind differs from the persisted kind
UnsupportedAssetManifestErrorAssetCatalog.parse() receives a version other than 1

AssetAlreadyExistsError and AssetNotFoundError carry the id. AssetKindMismatchError carries the id, expectedKind, and actualKind, the two kinds as AssetKind values. UnsupportedAssetManifestError carries the version.

A malformed shape passed to a parse() method throws a $ZodError, the base error class of zod/mini (z.core.$ZodError). Blank values, and asset kinds containing a colon or @, throw TypeError.

Loader and store configuration ​

ErrorThrown when
AssetLoaderAlreadyExistsErrorA registry already has a loader for the kind
AssetLoaderNotFoundErrorA load uses a kind with no registered loader
AssetTypeMismatchErrorThe same kind is used through another AssetType token
AssetNotReadyErrorSynchronous access occurs before an asset is ready

The loader errors and AssetTypeMismatchError carry the kind as an AssetKind. AssetNotReadyError carries the id and the current AssetStatus as status.

Batch failure ​

ts
interface AssetLoadFailure {
  readonly record: AssetRecord;
  readonly error: unknown;
}

class AssetBatchLoadError extends Error {
  readonly failures: readonly AssetLoadFailure[];

  constructor(failures: Iterable<AssetLoadFailure>);
}

AssetBatchLoadError collects every asset task that failed in one batch. A loader may reject with any JavaScript value, including undefined, so each failure's error is typed as unknown.

An exception thrown by onProgress rejects AssetLoadBatch.done directly. It is not wrapped in AssetBatchLoadError and does not appear in failures.