summaryrefslogtreecommitdiff
path: root/src/misc/errors.ts
blob: 18480f59d84b26853886508908f1f37b660a5b9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export const DOES_NOT_SUPPORT_FETCH = 0;

export const errors = {
  [DOES_NOT_SUPPORT_FETCH]: {
    message: 'Browser not supported!',
    detail: 'This browser does not support "fetch", please choose another one.',
  },
  default: {
    message: '出错了!\n 请尝试清理缓存和Cookie后重试',
  },
};

export type Err = { code: number };

export function deriveMessageFromError(err: Err) {
  const { code } = err;
  if (typeof code === 'number') {
    return errors[code];
  }
  return errors.default;
}