mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): more context in storage errors
This commit is contained in:
parent
630854ce26
commit
07416753be
@ -1,4 +1,5 @@
|
||||
import { StorageError } from 'app/store/enhancers/reduxRemember/errors';
|
||||
import { $projectId } from 'app/store/nanostores/projectId';
|
||||
import type { UseStore } from 'idb-keyval';
|
||||
import {
|
||||
clear,
|
||||
@ -24,14 +25,23 @@ export const idbKeyValDriver: Driver = {
|
||||
try {
|
||||
return get(key, $idbKeyValStore.get());
|
||||
} catch (originalError) {
|
||||
throw new StorageError({ key, originalError });
|
||||
throw new StorageError({
|
||||
key,
|
||||
projectId: $projectId.get(),
|
||||
originalError,
|
||||
});
|
||||
}
|
||||
},
|
||||
setItem: (key, value) => {
|
||||
try {
|
||||
return set(key, value, $idbKeyValStore.get());
|
||||
} catch (originalError) {
|
||||
throw new StorageError({ key, value, originalError });
|
||||
throw new StorageError({
|
||||
key,
|
||||
value,
|
||||
projectId: $projectId.get(),
|
||||
originalError,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ export type StorageErrorArgs = {
|
||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct
|
||||
value?: any;
|
||||
originalError?: unknown;
|
||||
projectId?: string;
|
||||
};
|
||||
|
||||
export class StorageError extends Error {
|
||||
@ -15,14 +16,18 @@ export class StorageError extends Error {
|
||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct
|
||||
value?: any;
|
||||
originalError?: Error;
|
||||
projectId?: string;
|
||||
|
||||
constructor({ key, value, originalError }: StorageErrorArgs) {
|
||||
constructor({ key, value, originalError, projectId }: StorageErrorArgs) {
|
||||
super(`Error setting ${key}`);
|
||||
this.name = 'StorageSetError';
|
||||
this.key = key;
|
||||
if (value !== undefined) {
|
||||
this.value = value;
|
||||
}
|
||||
if (projectId !== undefined) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
if (originalError instanceof Error) {
|
||||
this.originalError = originalError;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user