vector-im-hydrogen-web/src/matrix/storage/common.js

36 lines
930 B
JavaScript
Raw Normal View History

2019-07-01 10:00:29 +02:00
export const STORE_NAMES = Object.freeze([
"session",
"roomState",
"roomSummary",
"timelineEvents",
"timelineFragments",
"pendingEvents",
]);
2019-04-04 09:27:31 +02:00
export const STORE_MAP = Object.freeze(STORE_NAMES.reduce((nameMap, name) => {
nameMap[name] = name;
return nameMap;
}, {}));
export class StorageError extends Error {
constructor(message, cause, value) {
let fullMessage = message;
if (cause) {
fullMessage += ": ";
2019-11-21 18:28:18 +01:00
if (typeof cause.name === "string") {
fullMessage += `(name: ${cause.name}) `;
}
if (typeof cause.code === "number") {
fullMessage += `(code: ${cause.name}) `;
}
fullMessage += cause.message;
}
super(fullMessage);
2019-07-26 22:03:57 +02:00
if (cause) {
this.errcode = cause.name;
}
this.cause = cause;
this.value = value;
}
}