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