Skip to content

Commit

Permalink
ScalafmtReflect: don't wrap in UnknownError
Browse files Browse the repository at this point in the history
This leads to a confusing "unknown error" message while masking the real
problem.
  • Loading branch information
kitbellew committed Apr 26, 2022
1 parent 7196593 commit 9840207
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ case class ScalafmtReflect(

private def parseConfigWith(
f: => Try[Object]
)(g: Throwable => ScalafmtDynamicError): Try[ScalafmtReflectConfig] =
)(g: Throwable => Throwable): Try[ScalafmtReflectConfig] =
f.map { configured =>
new ScalafmtReflectConfig(this)(configured.invoke("get"))
}.recoverWith { case ReflectionException(e) => Failure(g(e)) }
Expand All @@ -69,9 +69,7 @@ case class ScalafmtReflect(
}

def parseConfigFromString(text: String): Try[ScalafmtReflectConfig] =
parseConfigWith(parseConfigPre300(text))(
ScalafmtDynamicError.UnknownError.apply
)
parseConfigWith(parseConfigPre300(text))(identity)

private def parseConfigPost300(path: Path): Try[Object] = {
if (version < ScalafmtVersion(3, 0, 0, 7)) parseConfigPre300(path)
Expand Down

0 comments on commit 9840207

Please sign in to comment.