add types for errors
This commit is contained in:
@@ -5,6 +5,14 @@ import httpStatus from 'http-status';
|
||||
* @extends Error
|
||||
*/
|
||||
class ExtendableError extends Error {
|
||||
status: number;
|
||||
|
||||
data: any;
|
||||
|
||||
isPublic: boolean;
|
||||
|
||||
isOperational: boolean;
|
||||
|
||||
constructor(message: string, status: number, data: any, isPublic: boolean) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
@@ -13,6 +21,8 @@ class ExtendableError extends Error {
|
||||
this.data = data;
|
||||
this.isPublic = isPublic;
|
||||
this.isOperational = true; // This is required since bluebird 4 doesn't append it anymore.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore Couldn't get the compiler to love me
|
||||
Error.captureStackTrace(this, this.constructor.name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user