summaryrefslogtreecommitdiff
path: root/src/server/api/error.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/error.ts')
-rw-r--r--src/server/api/error.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/server/api/error.ts b/src/server/api/error.ts
new file mode 100644
index 0000000000..6b5c44cac2
--- /dev/null
+++ b/src/server/api/error.ts
@@ -0,0 +1,23 @@
+export class ApiError extends Error {
+ public message: string;
+ public code: string;
+ public id: string;
+ public kind: string;
+ public info?: any;
+
+ constructor(e?: { message: string, code: string, id: string, kind?: 'client' | 'server' }, info?: any) {
+ if (e == null) e = {
+ message: 'Internal error occurred. Please contact us if the error persists.',
+ code: 'INTERNAL_ERROR',
+ id: '5d37dbcb-891e-41ca-a3d6-e690c97775ac',
+ kind: 'server'
+ };
+
+ super(e.message);
+ this.message = e.message;
+ this.code = e.code;
+ this.id = e.id;
+ this.kind = e.kind || 'client';
+ this.info = info;
+ }
+}