Skip to content

Commit

Permalink
Migration: add an option to print just exception nodes rather than fu…
Browse files Browse the repository at this point in the history
…ll stack traces.

This makes it easier to find a short reproducible test case when
investigating a migration tool exception.

Change-Id: I13adf3e733d5cbbad58c9649420f7fdd072e4bdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115840
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
stereotype441 authored and commit-bot@chromium.org committed Sep 6, 2019
1 parent 28d16e1 commit 7e04e05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/nnbd_migration/tool/trial_migration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ main() async {
/// if its category contains the string.
const String categoryOfInterest = null;

/// Set this to `true` to cause just the exception nodes to be printed when
/// `categoryOfInterest` is non-null. Set this to `false` to cause the full
/// stack trace to be printed.
const bool printExceptionNodeOnly = false;

class _Listener implements NullabilityMigrationListener {
final groupedExceptions = <String, List<String>>{};

Expand Down Expand Up @@ -131,7 +136,11 @@ Exception $exception
$stackTrace
''';
if (categoryOfInterest != null && category.contains(categoryOfInterest)) {
print(detail);
if (printExceptionNodeOnly) {
print('$node');
} else {
print(detail);
}
}
(groupedExceptions[category] ??= []).add(detail);
++numExceptions;
Expand Down

0 comments on commit 7e04e05

Please sign in to comment.