Implement comprehensive error handling throughout the codebase by ensuring all error scenarios are properly caught, typed, and propagated. This includes:
Example:
// Bad
import(modulePath)
.then(module => {
module.default(req, res);
});
// Good
import(modulePath)
.then(module => {
module.default(req, res);
})
.catch(error => {
// Properly typed error with standardized code
const err = new Error('Module load failed');
err.code = 'EMODLOAD';
err.cause = error;
errorHandler(err);
});
// For error callbacks
service.use(
(config) => { /* ... */ },
(error) => {
// Properly handle error parameter
errorLogger(error);
throw error; // Propagate if needed
}
);
Enter the URL of a public GitHub repository