From 2cb63347a758dc65d8af8a3de4b190eb3c2e547f Mon Sep 17 00:00:00 2001 From: thosakwe Date: Mon, 19 Sep 2016 02:52:21 -0400 Subject: [PATCH] Better errors kinda --- lib/src/http/server.dart | 8 ++++++++ pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/http/server.dart b/lib/src/http/server.dart index 7400a136..3525ef09 100644 --- a/lib/src/http/server.dart +++ b/lib/src/http/server.dart @@ -29,6 +29,7 @@ typedef Future AngelConfigurer(AngelBase app); class Angel extends AngelBase { var _afterProcessed = new StreamController.broadcast(); var _beforeProcessed = new StreamController.broadcast(); + var _fatalErrorStream = new StreamController.broadcast(); var _onController = new StreamController.broadcast(); ServerGenerator _serverGenerator = (address, port) async => await HttpServer.bind(address, port); @@ -39,6 +40,9 @@ class Angel extends AngelBase { /// Fired before a request is processed. Always runs. Stream get beforeProcessed => _beforeProcessed.stream; + /// Fired on fatal errors. + Stream get fatalErrorStream => _fatalErrorStream.stream; + /// Fired whenever a controller is added to this instance. /// /// **NOTE**: This is a broadcast stream. @@ -312,6 +316,10 @@ class Angel extends AngelBase { _onError(e, [StackTrace stackTrace]) { stderr.write(e.toString()); if (stackTrace != null) stderr.write(stackTrace.toString()); + _fatalErrorStream.add({ + "error": e, + "stack": stackTrace + }); } Angel() : super() { diff --git a/pubspec.yaml b/pubspec.yaml index 66f86f61..46dc7166 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_framework -version: 1.0.0-dev.18 +version: 1.0.0-dev.19 description: Core libraries for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_framework