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 persisted or stored data
UnsupportedAssetManifestErrorAssetCatalog.parse() receives a version other than 1

Invalid persistence shapes and empty string values throw TypeError rather than a package-specific error.

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 entry is ready

AssetNotReadyError.status contains the current AssetStatus.

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.