mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
refactor(errors): extend errors from Error and add/assign statusCode
this is in preparation for updating the routes/handleException method, to get rid of "any" (and improve in general)
This commit is contained in:
parent
04f3b637f9
commit
ba5152de40
@ -1,8 +1,9 @@
|
|||||||
class NotFoundError {
|
class NotFoundError extends Error {
|
||||||
message: string;
|
statusCode: number;
|
||||||
|
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
this.message = message;
|
super(message);
|
||||||
|
this.name = "NotFoundError";
|
||||||
|
this.statusCode = 404;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
class ValidationError {
|
class ValidationError extends Error {
|
||||||
message: string;
|
statusCode: number;
|
||||||
|
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
this.message = message;
|
super(message)
|
||||||
|
this.name = "ValidationError";
|
||||||
|
this.statusCode = 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ValidationError;
|
export default ValidationError;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user