aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/data/common.ts
blob: 8d52abe5727faea19d6b26d6940832f7b7a8de3f (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";