Home > widget-integration > CartModule > handleBlockInitError
CartModule.handleBlockInitError() method
Handles errors that occur during cart block initialization. Override this method to customize error handling, add custom logging, or provide user feedback.
Signature:
protected handleBlockInitError(error: Error, block: AppBlock): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
error |
Error |
The error that occurred |
|
block |
The AppBlock that failed to initialize |
Returns:
void
Example
// Add custom error handling and user notification
protected handleBlockInitError(error, block) {
// Log to custom analytics service
this.analyticsService.trackError('cart_init_failed', {
blockId: block.id,
errorMessage: error.message,
errorStack: error.stack,
});
// Call parent error handler
super.handleBlockInitError(error, block);
// Show user-friendly error message
this.showCartErrorNotification('Unable to load cart. Please refresh the page.');
}