Skip to content

Commit

Permalink
Print pretty error message when Result.Failure is thrown (Backport #3391
Browse files Browse the repository at this point in the history
) (#3393)

The new `.getOrThrow` API allows to short-circuit the result of a
`Result`. This prints a correct error message when `Result.Failure` is
thrown in a method returning `T`, instead of returned via a method
returning `Result[T]`.

Backport of pull request: #3391

Pull Request: #3393
  • Loading branch information
lolgab authored Aug 19, 2024
1 parent 5c8c67f commit a710aaa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main/eval/src/mill/eval/Evaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ object Evaluator {
(for ((k, fs) <- evaluated.failing.items())
yield {
val fss = fs.map {
case ex: Result.Exception => ex.toString
case Result.Failure(t, _) => t
case Result.Exception(Result.Failure(t, _), _) => t
case ex: Result.Exception => ex.toString
}
s"${k.render} ${fss.iterator.mkString(", ")}"
}).mkString("\n")
Expand Down

0 comments on commit a710aaa

Please sign in to comment.