From 7e04e051cfee9230c5f252159c0416c767e5605d Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 6 Sep 2019 16:09:04 +0000 Subject: [PATCH] Migration: add an option to print just exception nodes rather than full 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 --- pkg/nnbd_migration/tool/trial_migration.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/nnbd_migration/tool/trial_migration.dart b/pkg/nnbd_migration/tool/trial_migration.dart index 0cc907bb44cac..f207d0766c890 100644 --- a/pkg/nnbd_migration/tool/trial_migration.dart +++ b/pkg/nnbd_migration/tool/trial_migration.dart @@ -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 = >{}; @@ -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;