Skip to main content

Function: createStoreErrorHandler()

createStoreErrorHandler(storeKey: string, operationName: string): ErrorHandlingFrontendStore

Defined in: src/stores/utils/storeErrorHandling.ts:42

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โ€‹

ErrorHandlingFrontendStore

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/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 window.electronAPI.sites.addSite(site);
},
createStoreErrorHandler("sites-operations", "createSite")
);