From f90bcfe27b1385d433a39fdffa0508674e2285b7 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Thu, 18 Apr 2019 12:09:37 -0400 Subject: [PATCH] Fix error handling --- lib/src/routes/routes.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index dfcc7a2..9396211 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -47,15 +47,15 @@ AngelConfigurer configureServer(FileSystem fileSystem) { var oldErrorHandler = app.errorHandler; app.errorHandler = (e, req, res) async { - if (!req.accepts('text/html', strict: true)) - return await oldErrorHandler(e, req, res); - else { - if (e.statusCode == 404) { - return await res + if (req.accepts('text/html', strict: true)) { + if (e.statusCode == 404 && req.accepts('text/html', strict: true)) { + await res .render('error', {'message': 'No file exists at ${req.uri}.'}); + } else { + await res.render('error', {'message': e.message}); } - - return await res.render('error', {'message': e.message}); + } else { + return await oldErrorHandler(e, req, res); } }; };