diff --git a/src/matrix/storage/common.ts b/src/matrix/storage/common.ts index 926ccbbf..8d2dd2d2 100644 --- a/src/matrix/storage/common.ts +++ b/src/matrix/storage/common.ts @@ -42,9 +42,9 @@ export const STORE_MAP: Readonly<{ [name : string]: string }> = Object.freeze(ST export class StorageError extends Error { errcode?: string; - cause?: Error; + cause: Error | null; - constructor(message: string, cause?: Error) { + constructor(message: string, cause: Error | null = null) { super(message); if (cause) { this.errcode = cause.name; diff --git a/src/matrix/storage/idb/error.ts b/src/matrix/storage/idb/error.ts index 02953886..1c6875fb 100644 --- a/src/matrix/storage/idb/error.ts +++ b/src/matrix/storage/idb/error.ts @@ -21,7 +21,7 @@ export class IDBError extends StorageError { storeName: string; databaseName: string; - constructor(message: string, source, cause: DOMException | null) { + constructor(message: string, source, cause: DOMException | null = null) { const storeName = source?.name || ""; const databaseName = source?.transaction?.db?.name || ""; let fullMessage = `${message} on ${databaseName}.${storeName}`; @@ -37,7 +37,7 @@ export class IDBError extends StorageError { if (cause) { fullMessage += cause.message; } - super(fullMessage, cause || undefined); + super(fullMessage, cause); this.storeName = storeName; this.databaseName = databaseName; }