Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

don't swallow stack traces on unchecked exception #306

Merged
merged 1 commit into from
Jun 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

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