This commit is contained in:
thosakwe 2017-01-20 17:46:12 -05:00
parent e82cbc312c
commit 43309519cd

View file

@ -17,7 +17,7 @@ configureAfter(Angel app) async {
// Static server, and pub serve while in development // Static server, and pub serve while in development
await app.configure(new PubServeLayer()); await app.configure(new PubServeLayer());
await app.configure(new VirtualDirectory()); await app.configure(new VirtualDirectory());
// Set our application up to handle different errors. // Set our application up to handle different errors.
var errors = new ErrorHandler(handlers: { var errors = new ErrorHandler(handlers: {
404: (req, res) async => 404: (req, res) async =>
@ -26,13 +26,14 @@ configureAfter(Angel app) async {
}); });
errors.fatalErrorHandler = (AngelFatalError e) async { errors.fatalErrorHandler = (AngelFatalError e) async {
e.request.response var req = await RequestContext.from(e.request, app);
..statusCode = 500 var res = new ResponseContext(e.request.response, app);
..writeln('500 Internal Server Error: ${e.error}') res.render('error', {'message': 'Internal Server Error: ${e.error}'});
..writeln(e.stack); await app.sendRequest(e.request, req, res);
await e.request.response.close();
}; };
app.get('/trump', () => throw new Exception('MAGA'));
// Throw a 404 if no route matched the request // Throw a 404 if no route matched the request
app.after.add(errors.throwError()); app.after.add(errors.throwError());