Better errors
This commit is contained in:
parent
4ad4180f22
commit
462c4f4a79
3 changed files with 80 additions and 76 deletions
|
@ -1,6 +1,6 @@
|
||||||
# angel_framework
|
# 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)
|
[![build status](https://travis-ci.org/angel-dart/framework.svg)](https://travis-ci.org/angel-dart/framework)
|
||||||
|
|
||||||
Core libraries for the Angel Framework.
|
Core libraries for the Angel Framework.
|
||||||
|
|
|
@ -190,6 +190,7 @@ class Angel extends AngelBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future handleRequest(HttpRequest request) async {
|
Future handleRequest(HttpRequest request) async {
|
||||||
|
try {
|
||||||
_beforeProcessed.add(request);
|
_beforeProcessed.add(request);
|
||||||
|
|
||||||
final req = await RequestContext.from(request, this);
|
final req = await RequestContext.from(request, this);
|
||||||
|
@ -252,8 +253,8 @@ class Angel extends AngelBase {
|
||||||
new AngelFatalError(request: request, error: e, stack: st));
|
new AngelFatalError(request: request, error: e, stack: st));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_fatalErrorStream
|
_fatalErrorStream.add(
|
||||||
.add(new AngelFatalError(request: request, error: e, stack: st));
|
new AngelFatalError(request: request, error: e, stack: st));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -272,7 +273,8 @@ class Angel extends AngelBase {
|
||||||
request.response.headers.set(key, res.headers[key]);
|
request.response.headers.set(key, res.headers[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.response.headers.chunkedTransferEncoding = res.chunked ?? true;
|
request.response.headers.chunkedTransferEncoding =
|
||||||
|
res.chunked ?? true;
|
||||||
|
|
||||||
request.response
|
request.response
|
||||||
..statusCode = res.statusCode
|
..statusCode = res.statusCode
|
||||||
|
@ -280,8 +282,13 @@ class Angel extends AngelBase {
|
||||||
..add(res.buffer.takeBytes());
|
..add(res.buffer.takeBytes());
|
||||||
await request.response.close();
|
await request.response.close();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e, st) {
|
||||||
failSilently(request, res);
|
_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);
|
_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.
|
/// Starts the server, wrapped in a [runZoned] call.
|
||||||
void listen({InternetAddress address, int port: 3000}) {
|
void listen({InternetAddress address, int port: 3000}) {
|
||||||
runZoned(() async {
|
runZoned(() async {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_framework
|
name: angel_framework
|
||||||
version: 1.0.0-dev.45
|
version: 1.0.0-dev.46
|
||||||
description: Core libraries for the Angel framework.
|
description: Core libraries for the Angel framework.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_framework
|
homepage: https://github.com/angel-dart/angel_framework
|
||||||
|
|
Loading…
Reference in a new issue