From 43309519cd1357c41ecbdd8316a3556a6b18c982 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Fri, 20 Jan 2017 17:46:12 -0500 Subject: [PATCH] Bam --- lib/src/routes/routes.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index aa9b14b..ea0b218 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -17,7 +17,7 @@ configureAfter(Angel app) async { // Static server, and pub serve while in development await app.configure(new PubServeLayer()); await app.configure(new VirtualDirectory()); - + // Set our application up to handle different errors. var errors = new ErrorHandler(handlers: { 404: (req, res) async => @@ -26,13 +26,14 @@ configureAfter(Angel app) async { }); errors.fatalErrorHandler = (AngelFatalError e) async { - e.request.response - ..statusCode = 500 - ..writeln('500 Internal Server Error: ${e.error}') - ..writeln(e.stack); - await e.request.response.close(); + var req = await RequestContext.from(e.request, app); + var res = new ResponseContext(e.request.response, app); + res.render('error', {'message': 'Internal Server Error: ${e.error}'}); + await app.sendRequest(e.request, req, res); }; + app.get('/trump', () => throw new Exception('MAGA')); + // Throw a 404 if no route matched the request app.after.add(errors.throwError());