Files
ChessHub/backend/util/errors.js
T
2023-07-06 19:28:19 +05:30

23 lines
461 B
JavaScript

class NotFoundError {
constructor(message) {
this.message = message;
this.status = 404;
}
}
class NotAuthError {
constructor(message) {
this.message = message;
this.status = 401;
}
}
function catchAsync(callback) {
return (req, res, next) => {
callback(req, res, next).catch(next);
};
}
exports.NotFoundError = NotFoundError;
exports.NotAuthError = NotAuthError;
exports.catchAsync = catchAsync