From ff1a39d04e53b428e34d46c55ecd6689189b5443 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sat, 31 Oct 2020 18:18:04 +0800 Subject: chore: run ts-migrate --- src/misc/errors.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/misc/errors.ts (limited to 'src/misc/errors.ts') diff --git a/src/misc/errors.ts b/src/misc/errors.ts new file mode 100644 index 0000000..1bc369a --- /dev/null +++ b/src/misc/errors.ts @@ -0,0 +1,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: 'Oops, something went wrong!', + }, +}; + +export type Err = { code: number }; + +export function deriveMessageFromError(err: Err) { + const { code } = err; + if (typeof code === 'number') { + return errors[code]; + } + return errors.default; +} -- cgit v1.3.1