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

Unified Diff: pkg/stack_trace/lib/src/stack_zone_specification.dart

Issue 556363004: Add an error callback to StackZoneSpecification. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/stack_trace/lib/src/chain.dart ('k') | pkg/stack_trace/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/stack_trace/lib/src/stack_zone_specification.dart
diff --git a/pkg/stack_trace/lib/src/stack_zone_specification.dart b/pkg/stack_trace/lib/src/stack_zone_specification.dart
index 9a4f7c05af10f18893f1d9f0b0acb8b55fd0318b..292da65286c4cde06397c07edcb6f5e143afcce5 100644
--- a/pkg/stack_trace/lib/src/stack_zone_specification.dart
+++ b/pkg/stack_trace/lib/src/stack_zone_specification.dart
@@ -56,7 +56,8 @@ class StackZoneSpecification {
handleUncaughtError: handleUncaughtError,
registerCallback: registerCallback,
registerUnaryCallback: registerUnaryCallback,
- registerBinaryCallback: registerBinaryCallback);
+ registerBinaryCallback: registerBinaryCallback,
+ errorCallback: errorCallback);
}
/// Returns the current stack chain.
@@ -88,7 +89,9 @@ class StackZoneSpecification {
var node = _createNode(level + 1);
future.then(completer.complete).catchError((e, stackTrace) {
if (stackTrace == null) stackTrace = new Trace.current();
- if (_chains[stackTrace] == null) _chains[stackTrace] = node;
+ if (stackTrace is! Chain && _chains[stackTrace] == null) {
+ _chains[stackTrace] = node;
+ }
completer.completeError(e, stackTrace);
});
return completer.future;
@@ -105,7 +108,9 @@ class StackZoneSpecification {
return stream.transform(new StreamTransformer.fromHandlers(
handleError: (error, stackTrace, sink) {
if (stackTrace == null) stackTrace = new Trace.current();
- if (_chains[stackTrace] == null) _chains[stackTrace] = node;
+ if (stackTrace is! Chain && _chains[stackTrace] == null) {
+ _chains[stackTrace] = node;
+ }
sink.addError(error, stackTrace);
}));
}
@@ -163,6 +168,26 @@ class StackZoneSpecification {
}
}
+ /// Attaches the current stack chain to [stackTrace], replacing it if
+ /// necessary.
+ AsyncError errorCallback(Zone self, ZoneDelegate parent, Zone zone,
+ Object error, StackTrace stackTrace) {
+ var asyncError = parent.errorCallback(zone, error, stackTrace);
+ if (asyncError != null) {
+ error = asyncError.error;
+ stackTrace = asyncError.stackTrace;
+ }
+
+ // Go up two levels to get through [_CustomZone.errorCallback].
+ if (stackTrace == null) {
+ stackTrace = _createNode(2).toChain();
+ } else {
+ if (_chains[stackTrace] == null) _chains[stackTrace] = _createNode(2);
+ }
+
+ return new AsyncError(error, stackTrace);
+ }
+
/// Creates a [_Node] with the current stack trace and linked to
/// [_currentNode].
///
« no previous file with comments | « pkg/stack_trace/lib/src/chain.dart ('k') | pkg/stack_trace/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698