File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 40
40
*/
41
41
package com .oracle .graal .python .runtime .formatting ;
42
42
43
+ import java .io .PrintWriter ;
44
+ import java .io .StringWriter ;
43
45
import java .util .Formatter ;
44
46
import java .util .regex .Matcher ;
45
47
import java .util .regex .Pattern ;
46
48
49
+ import com .oracle .graal .python .PythonLanguage ;
47
50
import com .oracle .graal .python .builtins .objects .type .TypeNodes .GetNameNode ;
48
51
import com .oracle .graal .python .nodes .object .GetClassNode ;
52
+ import com .oracle .graal .python .runtime .PythonOptions ;
49
53
import com .oracle .graal .python .util .PythonUtils ;
50
54
import com .oracle .truffle .api .CompilerAsserts ;
51
55
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
@@ -128,7 +132,15 @@ public String format(String format, Object... args) {
128
132
129
133
@ TruffleBoundary
130
134
private static String getMessage (Throwable exception ) {
131
- return exception .getClass ().getSimpleName () + ": " + exception .getMessage ();
135
+ String message = exception .getClass ().getSimpleName () + ": " + exception .getMessage ();
136
+ if (PythonOptions .isWithJavaStacktrace (PythonLanguage .get (null ))) {
137
+ StringWriter writer = new StringWriter ();
138
+ try (PrintWriter pw = new PrintWriter (writer )) {
139
+ exception .printStackTrace (pw );
140
+ }
141
+ message += "\n \n Java stack trace:\n " + writer ;
142
+ }
143
+ return message ;
132
144
}
133
145
134
146
private static String getClassName (Object obj ) {
You can’t perform that action at this time.
0 commit comments