1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/lib/error/base-error.ts

27 lines
583 B
TypeScript
Raw Normal View History

class BaseError extends Error {
readonly statusCode: number;
constructor(message: string, statusCode: number, name: string) {
super();
this.name = name;
this.message = message;
this.statusCode = statusCode;
Error.captureStackTrace(this, this.constructor);
}
toJSON(): object {
return {
isJoi: true,
name: this.constructor.name,
details: [
{
message: this.message,
},
],
};
}
}
export default BaseError;