in magenta-lib/src/main/scala/magenta/logging.scala [151:178]
def withFailureHandling[T](
reporter: DeployReporter
)(block: DeployReporter => T): T = {
try {
try {
block(reporter)
} catch {
case f: FailException =>
send(reporter, ContextMessage.FailContext(reporter.messageStack.head))
throw f
case t: Throwable =>
// build exception (and send fail message) first
val message = reporter.messageStack.head
val exception = failException(
reporter,
s"Unhandled exception in ${message.text}",
t
)
send(reporter, ContextMessage.FailContext(message))
throw exception
}
} catch {
case f: FailException =>
throw if (reporter.previousReporter.isEmpty && f.getCause != null)
f.getCause
else f
}
}