From f7f9cd6d9751988e6b235c389073fc34971f4ea1 Mon Sep 17 00:00:00 2001 From: Juliano Alves Date: Fri, 21 Oct 2022 15:53:05 +0100 Subject: [PATCH] Prefix error messages with [quill] when switch is on --- .../src/main/scala/io/getquill/util/MacroContextExt.scala | 6 +++--- quill-engine/src/main/scala/io/getquill/util/Messages.scala | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quill-core/src/main/scala/io/getquill/util/MacroContextExt.scala b/quill-core/src/main/scala/io/getquill/util/MacroContextExt.scala index 8d6d7846ad..01761cf356 100644 --- a/quill-core/src/main/scala/io/getquill/util/MacroContextExt.scala +++ b/quill-core/src/main/scala/io/getquill/util/MacroContextExt.scala @@ -2,7 +2,7 @@ package io.getquill.util import io.getquill.idiom.Idiom import io.getquill.util.IndentUtil._ -import io.getquill.util.Messages.{ debugEnabled, prettyPrint } +import io.getquill.util.Messages.{ debugEnabled, errorPrefix, prettyPrint } import io.getquill.quat.VerifyNoBranches import scala.reflect.macros.blackbox.{ Context => MacroContext } @@ -14,10 +14,10 @@ object MacroContextExt { implicit class RichContext(c: MacroContext) { def error(msg: String): Unit = - c.error(c.enclosingPosition, msg) + c.error(c.enclosingPosition, if (errorPrefix) s"[quill] $msg" else msg) def fail(msg: String): Nothing = - c.abort(c.enclosingPosition, msg) + c.abort(c.enclosingPosition, if (errorPrefix) s"[quill] $msg" else msg) def warn(msg: String): Unit = c.warning(c.enclosingPosition, msg) diff --git a/quill-engine/src/main/scala/io/getquill/util/Messages.scala b/quill-engine/src/main/scala/io/getquill/util/Messages.scala index ecc8edf19a..312a8a1ca1 100644 --- a/quill-engine/src/main/scala/io/getquill/util/Messages.scala +++ b/quill-engine/src/main/scala/io/getquill/util/Messages.scala @@ -34,6 +34,7 @@ object Messages { def disableReturning = cache("quill.query.disableReturning", variable("quill.query.disableReturning", "quill_query_disableReturning", "false").toBoolean) def logBinds = cache("quill.binds.log", variable("quill.binds.log", "quill_binds_log", "false").toBoolean) def queryTooLongForLogs = cache("quill.query.tooLong", variable("quill.query.tooLong", "quill_query_tooLong", "200").toInt) + def errorPrefix = cache("quill.error.prefix", variable("quill.error.prefix", "quill_error_prefix", "false").toBoolean) sealed trait LogToFile object LogToFile {