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

Unified Diff: pkg/analyzer/lib/src/task/driver.dart

Issue 1783853002: Improve the error message when there is an infinite loop in tasks (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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: pkg/analyzer/lib/src/task/driver.dart
diff --git a/pkg/analyzer/lib/src/task/driver.dart b/pkg/analyzer/lib/src/task/driver.dart
index b729a2b95e56f39811e1d00fee46b583a8eee2ff..cb4da98ff0c61f2e14733dac1e00c60b9ae22c2d 100644
--- a/pkg/analyzer/lib/src/task/driver.dart
+++ b/pkg/analyzer/lib/src/task/driver.dart
@@ -501,10 +501,36 @@ class InfiniteTaskLoopException extends AnalysisException {
* Initialize a newly created exception to represent a failed attempt to
* perform the given [task] due to the given [dependencyCycle].
*/
- InfiniteTaskLoopException(AnalysisTask task, this.dependencyCycle,
- [this.cyclicPath])
- : super(
- 'Infinite loop while performing task ${task.descriptor.name} for ${task.target}');
+ InfiniteTaskLoopException(AnalysisTask task, List<WorkItem> dependencyCycle,
+ [List<TargetedResult> cyclicPath])
+ : this.dependencyCycle = dependencyCycle,
+ this.cyclicPath = cyclicPath,
+ super(_composeMessage(task, dependencyCycle, cyclicPath));
+
+ /**
+ * Compose an error message based on the data we have available.
+ */
+ static String _composeMessage(AnalysisTask task,
+ List<WorkItem> dependencyCycle, List<TargetedResult> cyclicPath) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.write('Infinite loop while performing task ');
+ buffer.write(task.descriptor.name);
+ buffer.write(' for ');
+ buffer.writeln(task.target);
+ buffer.writeln(' Dependency Cycle:');
+ for (WorkItem item in dependencyCycle) {
+ buffer.write(' ');
+ buffer.writeln(item);
+ }
+ if (cyclicPath != null) {
+ buffer.writeln(' Cyclic Path:');
+ for (TargetedResult result in cyclicPath) {
+ buffer.write(' ');
+ buffer.writeln(result);
+ }
+ }
+ return buffer.toString();
+ }
}
/**
« 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