Skip to content

Commit

Permalink
Prefix error messages with [quill] when switch is on
Browse files Browse the repository at this point in the history
  • Loading branch information
juliano committed Oct 21, 2022
1 parent bfad9fc commit f7f9cd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f7f9cd6

Please sign in to comment.