Initial commit: teaching institution management API.
Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// /utils/AppError.js
|
||||
|
||||
const errors = require('./errors.json');
|
||||
|
||||
class AppError extends Error {
|
||||
constructor(errorCode, details = null, overrideMessage = null) {
|
||||
const errorDef = errors[errorCode] || errors.INTERNAL_SERVER_ERROR;
|
||||
const message = overrideMessage || errorDef.en;
|
||||
|
||||
super(message);
|
||||
this.name = 'AppError';
|
||||
this.errorCode = errorCode in errors ? errorCode : 'INTERNAL_SERVER_ERROR';
|
||||
this.statusCode = errorDef.statusCode || 500;
|
||||
this.details = details;
|
||||
this.overrideMessage = overrideMessage;
|
||||
this.isOperational = true;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AppError;
|
||||
Reference in New Issue
Block a user