summaryrefslogtreecommitdiff
path: root/src/misc/errors.ts
diff options
context:
space:
mode:
authorHaishan <[email protected]>2020-10-31 18:18:04 +0800
committerHaishan <[email protected]>2020-11-01 17:42:52 +0800
commitff1a39d04e53b428e34d46c55ecd6689189b5443 (patch)
tree94a60abe3d28a1d729b877356bdd38d75ce655a5 /src/misc/errors.ts
parente62c9165481ef12ee2310dee1c32f890b3fe4b78 (diff)
chore: run ts-migrate
Diffstat (limited to 'src/misc/errors.ts')
-rw-r--r--src/misc/errors.ts21
1 files changed, 21 insertions, 0 deletions
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;
+}