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

Unified Diff: utils/pub/utils.dart

Issue 11821006: Unwrap AsyncErrors to find real error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « utils/pub/http.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/utils.dart
diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
index b922d845d4013de9e3132acb6033f3e2e5fa86b4..c3503316e85e88a954606b9e5a38ff9b84ed9fd0 100644
--- a/utils/pub/utils.dart
+++ b/utils/pub/utils.dart
@@ -183,3 +183,14 @@ void mapAddAll(Map destination, Map source) =>
/// replacing `+` with ` `.
String urlDecode(String encoded) =>
decodeUriComponent(encoded.replaceAll("+", " "));
+
+/// When an error is rethrown in an async callback, you can end up with nested
+/// AsyncErrors. This unwraps them to find the real originating error.
+// TODO(rnystrom): Remove this when #7781 is fixed.
nweiz 2013/01/08 23:05:13 Nit: I usually put TODOs above dartdoc comments. I
Bob Nystrom 2013/01/08 23:07:23 Done.
+getRealError(error) {
+ while (error != null && error is AsyncError) {
nweiz 2013/01/08 23:05:13 "error != null" is unnecessary here. null isn't an
Bob Nystrom 2013/01/08 23:07:23 Done.
+ error = error.error;
+ }
+
+ return error;
+}
« no previous file with comments | « utils/pub/http.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698