mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
public commit
This commit is contained in:
37
app/src/core/errors.ts
Normal file
37
app/src/core/errors.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export class Exception extends Error {
|
||||
code = 400;
|
||||
override name = "Exception";
|
||||
|
||||
constructor(message: string, code?: number) {
|
||||
super(message);
|
||||
if (code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
error: this.message,
|
||||
type: this.name
|
||||
//message: this.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class BkndError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
public details?: Record<string, any>,
|
||||
public type?: string
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type ?? "unknown",
|
||||
message: this.message,
|
||||
details: this.details
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user