@@ -8,6 +8,7 @@ import dotty.tools.dotc.quoted.QuotesCache
8
8
import dotty .tools .io .{AbstractFile , Directory , PlainDirectory , VirtualDirectory }
9
9
import dotty .tools .repl .AbstractFileClassLoader
10
10
import dotty .tools .dotc .reporting ._
11
+ import dotty .tools .dotc .config .Settings .Setting .value
11
12
import dotty .tools .dotc .util .ClasspathFromClassloader
12
13
import scala .quoted ._
13
14
import scala .quoted .staging .Compiler
@@ -40,7 +41,20 @@ private class QuoteDriver(appClassloader: ClassLoader) extends Driver:
40
41
setCompilerSettings(ctx1.fresh.setSetting(ctx1.settings.outputDir, outDir), settings)
41
42
}
42
43
43
- new QuoteCompiler ().newRun(ctx).compileExpr(exprBuilder) match
44
+ val compiledExpr =
45
+ try
46
+ new QuoteCompiler ().newRun(ctx).compileExpr(exprBuilder)
47
+ catch case ex : dotty.tools.FatalError =>
48
+ val enrichedMessage =
49
+ s """ An unhandled exception was thrown in the staging compiler.
50
+ |This might be caused by using an incorrect classloader
51
+ |when creating the `staging.Compiler` instance with `staging.Compiler.make`.
52
+ |For details, please refer to the documentation.
53
+ |For non-enriched exceptions, compile with -Yno-enrich-error-messages. """ .stripMargin
54
+ if ctx.settings.YnoEnrichErrorMessages .value(using ctx) then throw ex
55
+ else throw new Exception (enrichedMessage, ex)
56
+
57
+ compiledExpr match
44
58
case Right (value) =>
45
59
value.asInstanceOf [T ]
46
60
@@ -67,7 +81,6 @@ private class QuoteDriver(appClassloader: ClassLoader) extends Driver:
67
81
68
82
case _ => throw ex
69
83
end match
70
-
71
84
end run
72
85
73
86
override def initCtx : Context =
0 commit comments