Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: pkg/shelf/lib/src/middleware.dart

Issue 657543004: pkg/shelf: only catch errors in createMiddleware if an errorHandler is provided (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address CL comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/shelf/CHANGELOG.md ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/lib/src/middleware.dart
diff --git a/pkg/shelf/lib/src/middleware.dart b/pkg/shelf/lib/src/middleware.dart
index 228761dea6862084c17f9872997140779a4692c6..b81b70d7ed85e384723920702690573dc66e0281 100644
--- a/pkg/shelf/lib/src/middleware.dart
+++ b/pkg/shelf/lib/src/middleware.dart
@@ -54,17 +54,21 @@ Middleware createMiddleware({requestHandler(Request request),
if (responseHandler == null) responseHandler = (response) => response;
+ var onError = null;
+ if (errorHandler != null) {
+ onError = (error, stackTrace) {
+ if (error is HijackException) throw error;
+ return errorHandler(error, stackTrace);
+ };
+ }
+
return (Handler innerHandler) {
return (request) {
return syncFuture(() => requestHandler(request)).then((response) {
if (response != null) return response;
return syncFuture(() => innerHandler(request))
- .then((response) => responseHandler(response),
- onError: (error, stackTrace) {
- if (error is HijackException) throw error;
- return errorHandler(error, stackTrace);
- });
+ .then((response) => responseHandler(response), onError: onError);
});
};
};
« no previous file with comments | « pkg/shelf/CHANGELOG.md ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698