Is there an easy way to catch errors thrown during macro expansion?
Suppose I have the following code. When I invoke it, I would like to be able to catch and inspect the RuntimeException
thrown by fooMacro
.
def foo: Unit = macro fooMacro
def fooMacro(c: scala.reflect.macros.whitebox.Context) = {
throw new RuntimeException("bar")
}
You might hope that you could supply a Reporter
that would receive the exception, but actually it's stringified in the cake:
There's also -Ymacro-debug-verbose.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.