mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Switch errors to using nulls
This commit is contained in:
parent
50b7a8a3fd
commit
0b8acb51a4
@ -42,9 +42,9 @@ export const STORE_MAP: Readonly<{ [name : string]: string }> = Object.freeze(ST
|
|||||||
|
|
||||||
export class StorageError extends Error {
|
export class StorageError extends Error {
|
||||||
errcode?: string;
|
errcode?: string;
|
||||||
cause?: Error;
|
cause: Error | null;
|
||||||
|
|
||||||
constructor(message: string, cause?: Error) {
|
constructor(message: string, cause: Error | null = null) {
|
||||||
super(message);
|
super(message);
|
||||||
if (cause) {
|
if (cause) {
|
||||||
this.errcode = cause.name;
|
this.errcode = cause.name;
|
||||||
|
@ -21,7 +21,7 @@ export class IDBError extends StorageError {
|
|||||||
storeName: string;
|
storeName: string;
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
|
|
||||||
constructor(message: string, source, cause: DOMException | null) {
|
constructor(message: string, source, cause: DOMException | null = 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}`;
|
||||||
@ -37,7 +37,7 @@ export class IDBError extends StorageError {
|
|||||||
if (cause) {
|
if (cause) {
|
||||||
fullMessage += cause.message;
|
fullMessage += cause.message;
|
||||||
}
|
}
|
||||||
super(fullMessage, cause || undefined);
|
super(fullMessage, cause);
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
this.databaseName = databaseName;
|
this.databaseName = databaseName;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user