mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-24 20:14:53 +01:00
Add initial stab at annotating error
This commit is contained in:
parent
69ab345a89
commit
a31f6a2c52
@ -18,7 +18,10 @@ limitations under the License.
|
|||||||
import { StorageError } from "../common";
|
import { StorageError } from "../common";
|
||||||
|
|
||||||
export class IDBError extends StorageError {
|
export class IDBError extends StorageError {
|
||||||
constructor(message, source, cause) {
|
storeName: string
|
||||||
|
databaseName: string
|
||||||
|
|
||||||
|
constructor(message: string, source, cause: DOMException | null) {
|
||||||
const storeName = source?.name || "<unknown store>";
|
const storeName = source?.name || "<unknown store>";
|
||||||
const databaseName = source?.transaction?.db?.name || "<unknown db>";
|
const databaseName = source?.transaction?.db?.name || "<unknown db>";
|
||||||
let fullMessage = `${message} on ${databaseName}.${storeName}`;
|
let fullMessage = `${message} on ${databaseName}.${storeName}`;
|
||||||
@ -34,14 +37,14 @@ export class IDBError extends StorageError {
|
|||||||
if (cause) {
|
if (cause) {
|
||||||
fullMessage += cause.message;
|
fullMessage += cause.message;
|
||||||
}
|
}
|
||||||
super(fullMessage, cause);
|
super(fullMessage, cause || undefined);
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
this.databaseName = databaseName;
|
this.databaseName = databaseName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IDBRequestError extends IDBError {
|
export class IDBRequestError extends IDBError {
|
||||||
constructor(request, message = "IDBRequest failed") {
|
constructor(request: IDBRequest, message: string = "IDBRequest failed") {
|
||||||
const source = request.source;
|
const source = request.source;
|
||||||
const cause = request.error;
|
const cause = request.error;
|
||||||
super(message, source, cause);
|
super(message, source, cause);
|
||||||
@ -49,7 +52,7 @@ export class IDBRequestError extends IDBError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class IDBRequestAttemptError 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);
|
super(`${method}(${params.map(p => JSON.stringify(p)).join(", ")}) failed`, source, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user