Improve error handling of API (#4345)
* wip
* wip
* wip
* Update attached_notes.ts
* wip
* Refactor
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update call.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* ✌️
* Fix
This commit is contained in:
23
src/server/api/error.ts
Normal file
23
src/server/api/error.ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user