Better database errors in worker thread

This commit is contained in:
Fedor Indutny 2024-08-13 13:42:20 -07:00 committed by GitHub
parent 2cbc1a82b2
commit 6143888f6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 8 deletions

View file

@ -70,7 +70,13 @@ export type WrappedWorkerResponse =
| Readonly<{
type: 'response';
seq: number;
error: string | undefined;
error:
| Readonly<{
name: string;
message: string;
stack: string | undefined;
}>
| undefined;
errorKind: SqliteErrorKind | undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
response: any;
@ -382,7 +388,9 @@ export class MainSQL {
}
if (error) {
const errorObj = new Error(error);
const errorObj = new Error(error.message);
errorObj.stack = error.stack;
errorObj.name = error.name;
this.onError(errorKind ?? SqliteErrorKind.Unknown, errorObj);
pair.reject(errorObj);