@@ -3,9 +3,6 @@ package repl
3
3
4
4
import scala .language .unsafeNulls
5
5
6
- import java .lang .{ ClassLoader , ExceptionInInitializerError }
7
- import java .lang .reflect .InvocationTargetException
8
-
9
6
import dotc .* , core .*
10
7
import Contexts .* , Denotations .* , Flags .* , NameOps .* , StdNames .* , Symbols .*
11
8
import printing .ReplPrinter
@@ -170,9 +167,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
170
167
171
168
/** Render the stack trace of the underlying exception. */
172
169
def renderError (thr : Throwable , d : Denotation )(using Context ): Diagnostic =
173
- val cause = thr.getCause match
174
- case e : ExceptionInInitializerError => e.getCause
175
- case e => e
170
+ val cause = rootCause(thr)
176
171
// detect
177
172
// at repl$.rs$line$2$.<clinit>(rs$line$2:1)
178
173
// at repl$.rs$line$2.res1(rs$line$2)
@@ -186,7 +181,6 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
186
181
private def infoDiagnostic (msg : String , d : Denotation )(using Context ): Diagnostic =
187
182
new Diagnostic .Info (msg, d.symbol.sourcePos)
188
183
189
-
190
184
object Rendering :
191
185
final val REPL_WRAPPER_NAME_PREFIX = str.REPL_SESSION_LINE
192
186
@@ -196,3 +190,12 @@ object Rendering:
196
190
val text = printer.dclText(s)
197
191
text.mkString(ctx.settings.pageWidth.value, ctx.settings.printLines.value)
198
192
}
193
+
194
+ def rootCause (x : Throwable ): Throwable = x match
195
+ case _ : ExceptionInInitializerError |
196
+ _ : java.lang.reflect.InvocationTargetException |
197
+ _ : java.lang.reflect.UndeclaredThrowableException |
198
+ _ : java.util.concurrent.ExecutionException
199
+ if x.getCause != null =>
200
+ rootCause(x.getCause)
201
+ case _ => x
0 commit comments