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

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

Issue 116913003: Chain.terse shouldn't return an empty chain. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | pkg/stack_trace/test/chain_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/stack_trace/lib/src/chain.dart
diff --git a/pkg/stack_trace/lib/src/chain.dart b/pkg/stack_trace/lib/src/chain.dart
index f6e2f3fb33ae05eef135e63e688a40cbf5eedb27..4055bc847c7e1bb70f229627f4a55b371d7273c4 100644
--- a/pkg/stack_trace/lib/src/chain.dart
+++ b/pkg/stack_trace/lib/src/chain.dart
@@ -157,10 +157,19 @@ class Chain implements StackTrace {
/// This calls [Trace.terse] on every trace in [traces], and discards any
/// trace that contain only internal frames.
Chain get terse {
- return new Chain(traces.map((trace) => trace.terse).where((trace) {
+ var terseTraces = traces.map((trace) => trace.terse);
+ var nonEmptyTraces = terseTraces.where((trace) {
// Ignore traces that contain only internal processing.
return trace.frames.length > 1;
- }));
+ });
+
+ // If all the traces contain only internal processing, preserve the last
+ // (top-most) one so that the chain isn't empty.
+ if (nonEmptyTraces.isEmpty && terseTraces.isNotEmpty) {
+ return new Chain([terseTraces.last]);
+ }
+
+ return new Chain(nonEmptyTraces);
}
/// Converts [this] to a [Trace].
« no previous file with comments | « no previous file | pkg/stack_trace/test/chain_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698