From a31f6a2c523ee3a6e1e5323c6b9286dce96b8f1b Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 10 Aug 2021 09:35:27 -0700 Subject: [PATCH] Add initial stab at annotating error --- src/matrix/storage/idb/error.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/matrix/storage/idb/error.ts b/src/matrix/storage/idb/error.ts index 0b9de95c..3694b587 100644 --- a/src/matrix/storage/idb/error.ts +++ b/src/matrix/storage/idb/error.ts @@ -18,7 +18,10 @@ limitations under the License. import { StorageError } from "../common"; export class IDBError extends StorageError { - constructor(message, source, cause) { + storeName: string + databaseName: string + + constructor(message: string, source, cause: DOMException | null) { const storeName = source?.name || ""; const databaseName = source?.transaction?.db?.name || ""; let fullMessage = `${message} on ${databaseName}.${storeName}`; @@ -34,14 +37,14 @@ export class IDBError extends StorageError { if (cause) { fullMessage += cause.message; } - super(fullMessage, cause); + super(fullMessage, cause || undefined); this.storeName = storeName; this.databaseName = databaseName; } } export class IDBRequestError extends IDBError { - constructor(request, message = "IDBRequest failed") { + constructor(request: IDBRequest, message: string = "IDBRequest failed") { const source = request.source; const cause = request.error; super(message, source, cause); @@ -49,7 +52,7 @@ export class IDBRequestError extends IDBError { } export class IDBRequestAttemptError extends IDBError { - constructor(method, source, cause, params) { + constructor(method: string, source, cause: DOMException, params: any[]) { super(`${method}(${params.map(p => JSON.stringify(p)).join(", ")}) failed`, source, cause); } }