Better errors

This commit is contained in:
thosakwe 2017-01-14 10:39:11 -05:00
parent 4ad4180f22
commit 462c4f4a79
3 changed files with 80 additions and 76 deletions

View file

@ -1,6 +1,6 @@
# angel_framework
[![pub 1.0.0-dev.45](https://img.shields.io/badge/pub-1.0.0--dev.45-red.svg)](https://pub.dartlang.org/packages/angel_framework)
[![pub 1.0.0-dev.46](https://img.shields.io/badge/pub-1.0.0--dev.46-red.svg)](https://pub.dartlang.org/packages/angel_framework)
[![build status](https://travis-ci.org/angel-dart/framework.svg)](https://travis-ci.org/angel-dart/framework)
Core libraries for the Angel Framework.

View file

@ -190,6 +190,7 @@ class Angel extends AngelBase {
}
Future handleRequest(HttpRequest request) async {
try {
_beforeProcessed.add(request);
final req = await RequestContext.from(request, this);
@ -252,8 +253,8 @@ class Angel extends AngelBase {
new AngelFatalError(request: request, error: e, stack: st));
}
} else {
_fatalErrorStream
.add(new AngelFatalError(request: request, error: e, stack: st));
_fatalErrorStream.add(
new AngelFatalError(request: request, error: e, stack: st));
}
break;
@ -272,7 +273,8 @@ class Angel extends AngelBase {
request.response.headers.set(key, res.headers[key]);
}
request.response.headers.chunkedTransferEncoding = res.chunked ?? true;
request.response.headers.chunkedTransferEncoding =
res.chunked ?? true;
request.response
..statusCode = res.statusCode
@ -280,8 +282,13 @@ class Angel extends AngelBase {
..add(res.buffer.takeBytes());
await request.response.close();
}
} catch (e) {
failSilently(request, res);
} catch (e, st) {
_fatalErrorStream
.add(new AngelFatalError(request: request, error: e, stack: st));
}
} catch (e, st) {
_fatalErrorStream
.add(new AngelFatalError(request: request, error: e, stack: st));
}
}
@ -335,9 +342,6 @@ class Angel extends AngelBase {
_onController.add(controllers[configurer.findExpose().path] = configurer);
}
/// Fallback when an error is thrown while handling a request.
void failSilently(HttpRequest request, ResponseContext res) {}
/// Starts the server, wrapped in a [runZoned] call.
void listen({InternetAddress address, int port: 3000}) {
runZoned(() async {

View file

@ -1,5 +1,5 @@
name: angel_framework
version: 1.0.0-dev.45
version: 1.0.0-dev.46
description: Core libraries for the Angel framework.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_framework