aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/services/common.ts
diff options
context:
space:
mode:
Diffstat (limited to 'FrontEnd/src/app/services/common.ts')
-rw-r--r--FrontEnd/src/app/services/common.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/FrontEnd/src/app/services/common.ts b/FrontEnd/src/app/services/common.ts
new file mode 100644
index 00000000..3bb6b9d7
--- /dev/null
+++ b/FrontEnd/src/app/services/common.ts
@@ -0,0 +1,23 @@
+import localforage from "localforage";
+
+import { HttpNetworkError } from "@/http/common";
+
+export const dataStorage = localforage.createInstance({
+ name: "data",
+ description: "Database for offline data.",
+ driver: localforage.INDEXEDDB,
+});
+
+export class ForbiddenError extends Error {
+ constructor(message?: string) {
+ super(message);
+ }
+}
+
+export function throwIfNotNetworkError(e: unknown): void {
+ if (!(e instanceof HttpNetworkError)) {
+ throw e;
+ }
+}
+
+export type BlobOrStatus = Blob | "loading" | "error";