aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/services/common.ts
blob: 3bb6b9d74bf45395c531efcfd1df432d1381d968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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";