AssetLoadFail

View source

Event data for an asset load or save request that could not be completed.

The asset API publishes this payload through its event stream when a request fails. Use the operation label from AssetLoadOperation to distinguish load and save failures, then use the event data to decide how to handle the failed request.

Examples

import { AssetLoadFail, AssetLoadOperation } from '@wimaengine/asset'

const typeId = 'Texture' // TypeId for the asset family
const assetId = 0 // AssetId for the asset entry
const path = '/textures/player.png'
const reason = 'Network request failed'
const failure = new AssetLoadFail(typeId, assetId, path, reason)

console.log(failure.operation === AssetLoadOperation.Loading) // true
console.log(failure.path, failure.reason) // /textures/player.png Network request failed

Constructor


constructor(typeId: TypeId, assetId: AssetId, path: string, reason: string, operation?: number)

View source

Creates failure event data for an asset load or save operation.

The constructor stores every argument on the event. The operation defaults to AssetLoadOperation.Loading. Pass AssetLoadOperation.Saving when constructing a save failure.

Parameters

NameDescriptionDefault
typeId

Runtime type ID of the affected asset family.

—
assetId

Asset ID associated with the request.

—
path

Path used by the load or save request.

—
reason

Failure message or reason.

—
operation?

Failed operation from AssetLoadOperation.

AssetLoadOperation.Loading

Properties


typeId: TypeId

View source

Runtime type ID of the asset family involved in the failed request.

assetId: AssetId

View source

Packed asset ID associated with the failed request.