Task runner fails ungracefully when experiencing error
Opened this issue · 0 comments
ISSUE
When the task runner encounters an error (e.g. scalafmt
detects formatting issues), it falls over with a JavaScript error, and doesn't print the helpful error message telling the developer what to do next.
Steps to Reproduce
- Add a bunch of random tabs and line breaks to a Scala file (e.g. FeatureSwitches.scala)
- Kick off the
scalafmt
task in task-runner in the terminal by running$ ./tools/task-runner/runner.mjs validate-head/scala.mjs
Actual Results (include screenshots)
There's a whole lot of noise and you have to hunt for the useful information and deduce what action to take. I believe the task-runner falls over, on line 109 of task-runner.mjs, because context
is not available on the Error received by the catch()
.
This might have been introduced in the recent migration to ESM (#27262), although this is only a hunch.
On a broader point, I'm not sure if we need this much custom error handling, as I'd expect Listr to take care of it.
Expected Results (include screenshots)
I would expect to see a helpful error message, such as the one defined in scala.mjs
:
Run ${chalk.blue('./sbt scalafmt')} to format Scala files.