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

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 133213011: Avoid "cannot create a Trace from null" errors in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: re-upload Created 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/utils.dart
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 6d777135d9abc2b69d80448f8b652826872db08b..4a63ca3beaaeda001e13433919e889818d6b4d89 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -144,7 +144,14 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) {
var wrappedCallback = () {
new Future.sync(callback).then(completer.complete)
.catchError((e, stackTrace) {
- completer.completeError(e, new Chain.forTrace(stackTrace));
+ // [stackTrace] can be null if we're running without [captureStackChains],
+ // since dart:io will often throw errors without stack traces.
+ if (stackTrace != null) {
+ stackTrace = new Chain.forTrace(stackTrace);
+ } else {
+ stackTrace = new Chain([]);
+ }
+ completer.completeError(e, stackTrace);
});
};
@@ -152,7 +159,12 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) {
Chain.capture(wrappedCallback, onError: completer.completeError);
} else {
runZoned(wrappedCallback, onError: (e, stackTrace) {
- completer.completeError(e, new Chain([new Trace.from(stackTrace)]));
+ if (stackTrace == null) {
+ stackTrace = new Chain([new Trace.from(stackTrace)]);
+ } else {
+ stackTrace = new Chain([]);
+ }
+ completer.completeError(e, stackTrace);
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698