Skip to content

Commit

Permalink
don't swallow stack traces on unchecked exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Jun 24, 2022
1 parent dd84703 commit 4d3533e
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 4d3533e

Please # to comment.