A workaround (maybe) for a really annoying issue with error handling and how parameters get passed to what
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 33s

This commit is contained in:
Alan Bridgeman 2025-06-24 12:19:45 -05:00
parent a89bcbb625
commit 9a073f6dca

View file

@ -83,7 +83,19 @@ export function Controller<T extends { new (...args: any[]): BaseController }>()
console.log('[Controller.setup.<GET request>] Response:', res);
console.log('[Controller.setup.<GET request>] Next:', next);
try {
return await fn.bind(controller)(req, res, next);
}
catch(error) {
if(typeof next !== 'undefined') {
next(error);
return;
}
else {
// Because next is undefined and we still want to have Express handle the error we reject the promise
return Promise.reject(error);
}
}
});
});