File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
compiler/src/dotty/tools/repl Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change 1
1
package dotty .tools
2
2
package repl
3
3
4
- import java .lang .ClassLoader
4
+ import java .io .{ StringWriter , PrintWriter }
5
+ import java .lang .{ ClassLoader , ExceptionInInitializerError }
6
+ import java .lang .reflect .InvocationTargetException
5
7
6
8
import scala .util .control .NonFatal
7
9
@@ -70,10 +72,26 @@ private[repl] class Rendering(compiler: ReplCompiler,
70
72
/** Render value definition result */
71
73
def renderVal (d : Denotation )(implicit ctx : Context ): Option [String ] = {
72
74
val dcl = d.symbol.showUser
73
- val resultValue =
74
- if (d.symbol.is(Flags .Lazy )) Some (" <lazy>" )
75
- else valueOf(d.symbol)
76
75
77
- resultValue.map(value => s " $dcl = $value" )
76
+ try {
77
+ val resultValue =
78
+ if (d.symbol.is(Flags .Lazy )) Some (" <lazy>" )
79
+ else valueOf(d.symbol)
80
+
81
+ resultValue.map(value => s " $dcl = $value" )
82
+ }
83
+ catch { case ex : InvocationTargetException => Some (renderError(ex)) }
84
+ }
85
+
86
+ /** Render the stack trace of the underlying exception */
87
+ private def renderError (ex : InvocationTargetException ): String = {
88
+ val cause = ex.getCause match {
89
+ case ex : ExceptionInInitializerError => ex.getCause
90
+ case ex => ex
91
+ }
92
+ val sw = new StringWriter ()
93
+ val pw = new PrintWriter (sw)
94
+ cause.printStackTrace(pw)
95
+ sw.toString
78
96
}
79
97
}
You can’t perform that action at this time.
0 commit comments