parent
037837b551
commit
0e4a111f81
1714 changed files with 20803 additions and 11751 deletions
28
packages/backend/src/server/api/error.ts
Normal file
28
packages/backend/src/server/api/error.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
type E = { message: string, code: string, id: string, kind?: 'client' | 'server', httpStatusCode?: number };
|
||||
|
||||
export class ApiError extends Error {
|
||||
public message: string;
|
||||
public code: string;
|
||||
public id: string;
|
||||
public kind: string;
|
||||
public httpStatusCode?: number;
|
||||
public info?: any;
|
||||
|
||||
constructor(e?: E | null | undefined, info?: any | null | undefined) {
|
||||
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',
|
||||
httpStatusCode: 500
|
||||
};
|
||||
|
||||
super(e.message);
|
||||
this.message = e.message;
|
||||
this.code = e.code;
|
||||
this.id = e.id;
|
||||
this.kind = e.kind || 'client';
|
||||
this.httpStatusCode = e.httpStatusCode;
|
||||
this.info = info;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue