Add service name and method name to errors in misc services and middleware
This commit is contained in:
1 parent
0d99f1ac8a
commit
9381f842f3
6 files changed
+21
-3
No files matched your search
@@ -43,6 +43,7 @@ const isAllowed = (allowedRoles) => {
|
||||
}
|
||||
} catch (error) {
|
||||
error.status = 401;
|
||||
error.method = "isAllowed";
|
||||
error.service = SERVICE_NAME;
|
||||
next(error);
|
||||
return;
|
||||
|
||||
@@ -28,6 +28,7 @@ const verifyJWT = (req, res, next) => {
|
||||
const error = new Error(errorMessages.INVALID_AUTH_TOKEN); // Instantiate a new Error object for improperly formatted token
|
||||
error.status = 400;
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "verifyJWT";
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ const verifyOwnership = (Model, paramName) => {
|
||||
return;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "verifyOwnership";
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ const verifySuperAdmin = (req, res, next) => {
|
||||
const error = new Error(errorMessages.INVALID_AUTH_TOKEN); // Instantiate a new Error object for improperly formatted token
|
||||
error.status = 400;
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "verifySuperAdmin";
|
||||
next(error);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user