objection
Version:
An SQL-friendly ORM for Node.js
24 lines (19 loc) • 580 B
JavaScript
;
class NotFoundError extends Error {
constructor({ modelClass, data = {}, statusCode = 404, ...rest } = {}) {
super(rest.message || 'NotFoundError');
this.type = 'NotFound';
this.name = this.constructor.name;
this.data = { ...rest, ...data };
this.statusCode = statusCode;
// Add as non-enumerable in case people are passing instances of
// this error directly to `JSON.stringify`.
Object.defineProperty(this, 'modelClass', {
value: modelClass,
enumerable: false,
});
}
}
module.exports = {
NotFoundError,
};