Skip to content

Instantly share code, notes, and snippets.

@arturaz
Created March 7, 2023 16:50
Show Gist options
  • Save arturaz/5db742eee5df7a7c62ece88dd90c897b to your computer and use it in GitHub Desktop.
Save arturaz/5db742eee5df7a7c62ece88dd90c897b to your computer and use it in GitHub Desktop.
diff --git a/quill-sql/src/main/scala/io/getquill/util/Format.scala b/quill-sql/src/main/scala/io/getquill/util/Format.scala
index 31e8e7e1..040690ad 100644
--- a/quill-sql/src/main/scala/io/getquill/util/Format.scala
+++ b/quill-sql/src/main/scala/io/getquill/util/Format.scala
@@ -120,7 +120,9 @@ object Format {
linesTrimmedLast.mkString("\n")
val formatted =
- Try {
+ // We can't use `Try` here because it won't catch linking errors as those are considered
+ // fatal. But we don't want to crash on a missing dependency here, thus the try-catch.
+ try {
// val formatCls = classOf[ScalafmtFormat.type]
// val result = formatCls.getMethod("apply").invoke(null, encosedCode)
// println("============ GOT HERE ===========")
@@ -134,8 +136,11 @@ object Format {
.replace("_!=", "!="),
showErrorTrace
)
- }.getOrElse {
+ }
+ catch { (t: Throwable) =>
println("====== WARNING: Scalafmt Not Detected ====")
+ println("If you want to use the formatter, add the following to your build.sbt")
+ println("libraryDependencies += \"org.scalameta\" %% \"scalafmt-core\" % \"3.1.0\"")
encosedCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment