Error Handling
Error Handling
app.get('/this-page-does-not-exist', (req, res) async {
// 404 Not Found
throw new AngelHttpException.notFound();
});// Typically, you want to preserve the old error handler, unless you are
// completely replacing the functionality.
var oldErrorHandler = app.errorHandler;
app.errorHandler = (AngelHttpException e, RequestContext req, ResponseContext res) {
if (someCondition) {
// Do something else special...
} else {
// Otherwise, use the default functionality.
return oldErrorHandler(e, req, res);
}
}Next Up...
Last updated