Skip to content

basket.unexpectedError

basket.unexpectedError is an event on the Event Bus that occurs whenever an unexpected error is thrown.

Event body

none

Example

In this example we listen to basket.unexpectedError event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    storefront.eventBus.on('basket.unexpectedError', () => {
        console.log('An unexpected error has occurred');
    });
});

Example

In this example we use a Message Storage API to retrieve an array of past basket.unexpectedError events.

useStorefront((storefront) => {
    const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');

    const pastUnexpectedErrorEvents = messageStorageApi.getChannelMessages('basket.unexpectedError');

    if (pastUnexpectedErrorEvents.length > 0) {
        pastUnexpectedErrorEvents.forEach(({ body: eventBody }) => {
            console.log('perform action on every past event');
        });
    }
});

JS API reference