Skip to content

Commit

Permalink
Merge pull request #306 from scalacenter/dont-swallow-unchecked
Browse files Browse the repository at this point in the history
don't swallow stack traces on unchecked exception
  • Loading branch information
bjaglin authored Jun 25, 2022
2 parents dd84703 + 4d3533e commit 2243306
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/scala/scalafix/internal/sbt/ScalafixInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import scalafix.interfaces.{Scalafix => ScalafixAPI, _}
import scalafix.sbt.InvalidArgument

import scala.collection.JavaConverters._
import scala.util.control.NonFatal
import java.io.PrintStream

sealed trait Arg extends (ScalafixArguments => ScalafixArguments)
Expand Down Expand Up @@ -88,7 +87,9 @@ class ScalafixInterface private (
def withArgs(args: Arg*): ScalafixInterface = {
val newScalafixArguments = args.foldLeft(scalafixArguments) { (acc, arg) =>
try arg(acc)
catch { case NonFatal(e) => throw new InvalidArgument(e.getMessage) }
catch {
case e: ScalafixException => throw new InvalidArgument(e.getMessage)
}
}
new ScalafixInterface(newScalafixArguments, this.args ++ args)
}
Expand All @@ -101,7 +102,9 @@ class ScalafixInterface private (

def rulesThatWillRun(): Seq[ScalafixRule] =
try scalafixArguments.rulesThatWillRun().asScala
catch { case NonFatal(e) => throw new InvalidArgument(e.getMessage) }
catch {
case e: ScalafixException => throw new InvalidArgument(e.getMessage)
}

def validate(): Option[ScalafixException] =
Option(scalafixArguments.validate().orElse(null))
Expand Down

0 comments on commit 2243306

Please sign in to comment.