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 { StorageError } from 'app/store/enhancers/reduxRemember/errors';
|
||||||
|
import { $projectId } from 'app/store/nanostores/projectId';
|
||||||
import type { UseStore } from 'idb-keyval';
|
import type { UseStore } from 'idb-keyval';
|
||||||
import {
|
import {
|
||||||
clear,
|
clear,
|
||||||
@ -24,14 +25,23 @@ export const idbKeyValDriver: Driver = {
|
|||||||
try {
|
try {
|
||||||
return get(key, $idbKeyValStore.get());
|
return get(key, $idbKeyValStore.get());
|
||||||
} catch (originalError) {
|
} catch (originalError) {
|
||||||
throw new StorageError({ key, originalError });
|
throw new StorageError({
|
||||||
|
key,
|
||||||
|
projectId: $projectId.get(),
|
||||||
|
originalError,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setItem: (key, value) => {
|
setItem: (key, value) => {
|
||||||
try {
|
try {
|
||||||
return set(key, value, $idbKeyValStore.get());
|
return set(key, value, $idbKeyValStore.get());
|
||||||
} catch (originalError) {
|
} 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
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct
|
||||||
value?: any;
|
value?: any;
|
||||||
originalError?: unknown;
|
originalError?: unknown;
|
||||||
|
projectId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class StorageError extends Error {
|
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
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct
|
||||||
value?: any;
|
value?: any;
|
||||||
originalError?: Error;
|
originalError?: Error;
|
||||||
|
projectId?: string;
|
||||||
|
|
||||||
constructor({ key, value, originalError }: StorageErrorArgs) {
|
constructor({ key, value, originalError, projectId }: StorageErrorArgs) {
|
||||||
super(`Error setting ${key}`);
|
super(`Error setting ${key}`);
|
||||||
this.name = 'StorageSetError';
|
this.name = 'StorageSetError';
|
||||||
this.key = key;
|
this.key = key;
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
if (projectId !== undefined) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
if (originalError instanceof Error) {
|
if (originalError instanceof Error) {
|
||||||
this.originalError = originalError;
|
this.originalError = originalError;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user