Skip to content

Commit 585d059

Browse files
committed
feat(utils): enhance storage error handling and logging
- Add comprehensive error class hierarchy for storage operations - Implement structured error conversion for IndexedDB operations - Add input validation to prevent invalid data operations - Enhance error logging with detailed context and metadata - Improve error boundary integration in main application Classes added: - StorageError (abstract base) - IndexedDBError, QuotaExceededError, NotFoundError - ValidationError, ConnectionError, OperationAbortedError Utility functions: - isStorageError() type guard - convertIndexedDBError() for structured error handling
1 parent ed77b64 commit 585d059

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/utils/src/storage/dexie-storage-provider.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ import type { CatalogueEntity,CatalogueList } from './catalogue-db.js';
1515
import { CatalogueService } from './catalogue-db.js';
1616
import type { AddBookmarkParams, AddEntityParams, AddToHistoryParams, BatchAddResult, CatalogueStorageProvider, CreateListParams, ListStats, ShareAccessResult } from './catalogue-storage-provider.js';
1717
import {
18-
ConnectionError,
1918
convertIndexedDBError,
20-
IndexedDBError,
21-
NotFoundError,
22-
OperationAbortedError,
23-
QuotaExceededError,
2419
ValidationError,
2520
} from './errors.js';
2621

packages/utils/src/storage/errors.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ export class OperationAbortedError extends StorageError {
103103

104104
/**
105105
* Utility function to determine if an error is a storage error
106+
* @param error - The error to check
106107
*/
107-
export function isStorageError(error: unknown): error is StorageError {
108-
return error instanceof StorageError;
109-
}
108+
export const isStorageError = (error: unknown): error is StorageError =>
109+
error instanceof StorageError;
110110

111111
/**
112112
* Utility function to convert IndexedDB errors to structured storage errors
113+
* @param operation - The operation that failed
114+
* @param error - The original error
113115
*/
114-
export function convertIndexedDBError(
116+
export const convertIndexedDBError = (
115117
operation: string,
116118
error: unknown
117-
): StorageError {
119+
): StorageError => {
118120
if (isStorageError(error)) {
119121
return error;
120122
}
@@ -148,4 +150,4 @@ export function convertIndexedDBError(
148150
}
149151

150152
return new IndexedDBError(operation, new Error(String(error)));
151-
}
153+
};

0 commit comments

Comments
 (0)