Function: createStoreErrorHandler()
function createStoreErrorHandler(
storeKey: string,
operationName: string
): ErrorHandlingFrontendStore;
Defined in: src/stores/utils/storeErrorHandling.ts:46
Creates a standardized error handling context for store operations. Provides consistent error state management across different store modules.
Parametersโ
storeKeyโ
string
The key identifying the store for error tracking (e.g., "sites-operations", "sites-monitoring")
operationNameโ
string
The name of the specific operation being performed (e.g., "createSite", "deleteSite")
Returnsโ
Error handling context compatible with withErrorHandling function.
Remarksโ
This factory eliminates the need to repeatedly define the same error handling object structure across different store operations. It provides:
- Consistent error clearing before operations
- Standardized error state management on failures
- Proper loading state tracking during async operations
Exampleโ
await withErrorHandling(
async () => {
// Your async operation
await SiteService.addSite(site);
},
createStoreErrorHandler("sites-operations", "createSite")
);