From 7b031481609f9668db2a27d6a826c896577ef05d Mon Sep 17 00:00:00 2001 From: thosakwe Date: Tue, 20 Jun 2017 15:13:15 -0400 Subject: [PATCH] Patch --- .idea/workspace.xml | 203 ++++++++++----------------------------- lib/src/http/server.dart | 49 +++++++--- pubspec.yaml | 2 +- 3 files changed, 88 insertions(+), 166 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f012b5cd..48544501 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,9 +3,6 @@ - - - @@ -31,22 +28,22 @@ - + - + - + - - + + @@ -59,7 +56,7 @@ - + @@ -81,7 +78,7 @@ - + @@ -105,8 +102,8 @@ - - + + @@ -115,7 +112,7 @@ - + @@ -128,7 +125,7 @@ - + @@ -138,7 +135,7 @@ - + @@ -182,6 +179,7 @@ _injec writeln write( + _ _isClosed @@ -215,10 +213,10 @@ @@ -238,7 +236,7 @@ - + @@ -251,92 +249,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -488,7 +401,8 @@ - + + 1481237183504 @@ -595,7 +509,14 @@ - @@ -631,7 +552,7 @@ - @@ -644,25 +565,24 @@ - - + - - - - + + + + @@ -689,7 +609,8 @@ - @@ -906,9 +827,6 @@ - - - @@ -923,9 +841,6 @@ - - - @@ -933,9 +848,6 @@ - - - @@ -943,7 +855,6 @@ - @@ -951,7 +862,6 @@ - @@ -959,13 +869,12 @@ - - + @@ -973,7 +882,7 @@ - + @@ -983,9 +892,6 @@ - - - @@ -1003,7 +909,6 @@ - @@ -1011,7 +916,6 @@ - @@ -1027,7 +931,7 @@ - + @@ -1035,25 +939,16 @@ - - - - - - - - - - + @@ -1064,16 +959,16 @@ - + - + - - + + @@ -1081,8 +976,8 @@ - - + + @@ -1091,5 +986,13 @@ + + + + + + + + \ No newline at end of file diff --git a/lib/src/http/server.dart b/lib/src/http/server.dart index 836a40c8..914bbad3 100644 --- a/lib/src/http/server.dart +++ b/lib/src/http/server.dart @@ -11,7 +11,7 @@ import 'angel_base.dart'; import 'angel_http_exception.dart'; import 'controller.dart'; import 'fatal_error.dart'; -import 'hooked_service.dart'; +//import 'hooked_service.dart'; import 'request_context.dart'; import 'response_context.dart'; import 'routable.dart'; @@ -339,18 +339,37 @@ class Angel extends AngelBase { } _handleAngelHttpException(AngelHttpException e, StackTrace st, - RequestContext req, ResponseContext res) async { - res.statusCode = e.statusCode; - List accept = request.headers[HttpHeaders.ACCEPT] ?? ['*/*']; - if (accept.isEmpty || - accept.contains('*/*') || - accept.contains(ContentType.JSON.mimeType) || - accept.contains("application/javascript")) { - res.serialize(e.toMap(), - contentType: res.headers[HttpHeaders.CONTENT_TYPE] ?? - ContentType.JSON.mimeType); - } else { - await errorHandler(e, req, res); + RequestContext req, ResponseContext res, HttpRequest request) async { + try { + if (req == null || res == null) { + _fatalErrorStream.add(new AngelFatalError( + request: request, + error: e?.error ?? + e ?? + new Exception('Unhandled exception while handling request.'), + stack: st)); + return; + } + + res.statusCode = e.statusCode; + List accept = request?.headers[HttpHeaders.ACCEPT] ?? ['*/*']; + if (accept.isEmpty || + accept.contains('*/*') || + accept.contains(ContentType.JSON.mimeType) || + accept.contains("application/javascript")) { + res.serialize(e.toMap(), + contentType: res.headers[HttpHeaders.CONTENT_TYPE] ?? + ContentType.JSON.mimeType); + } else { + await errorHandler(e, req, res); + } + } catch (_) { + _fatalErrorStream.add(new AngelFatalError( + request: request, + error: e?.error ?? + e ?? + new Exception('Unhandled exception while handling request.'), + stack: st)); } } @@ -396,14 +415,14 @@ class Angel extends AngelBase { // 'Handler completed successfully, did not terminate response: $handler'); } } on AngelHttpException catch (e, st) { - return await _handleAngelHttpException(e, st, req, res); + return await _handleAngelHttpException(e, st, req, res, request); } } try { await sendResponse(request, req, res); } on AngelHttpException catch (e, st) { - return await _handleAngelHttpException(e, st, req, res); + return await _handleAngelHttpException(e, st, req, res, request); } catch (e, st) { _fatalErrorStream .add(new AngelFatalError(request: request, error: e, stack: st)); diff --git a/pubspec.yaml b/pubspec.yaml index 9e8946f2..737a0339 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_framework -version: 1.0.4 +version: 1.0.5+1 description: A high-powered HTTP server with DI, routing and more. author: Tobe O homepage: https://github.com/angel-dart/angel_framework