From 4b590bbf3f4dd6db4cdd94cc0c3945e980a14688 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:26:09 -0700 Subject: [PATCH] ScalafmtReflect: don't wrap in UnknownError This leads to a confusing "unknown error" message while masking the real problem. --- .../main/scala/org/scalafmt/dynamic/ScalafmtReflect.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtReflect.scala b/scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtReflect.scala index a9a475a4d8..e1f3731f7e 100644 --- a/scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtReflect.scala +++ b/scalafmt-dynamic/src/main/scala/org/scalafmt/dynamic/ScalafmtReflect.scala @@ -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)) } @@ -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)