diff --git a/jnius/jnius_export_class.pxi b/jnius/jnius_export_class.pxi index a688e2b0..c7ab5adb 100644 --- a/jnius/jnius_export_class.pxi +++ b/jnius/jnius_export_class.pxi @@ -14,6 +14,15 @@ class JavaException(Exception): self.stacktrace = stacktrace Exception.__init__(self, message) + def __str__(self): + ''' + Override __str__ so that we can see the Java stacktrace + ''' + rtr = self.args[0] + if self.stacktrace is not None: + rtr += '\n' + '\n\t'.join(self.stacktrace) + return rtr + cdef class JavaObject(object): '''Can contain any Java object. Used to store instance, or whatever. diff --git a/jnius/jnius_utils.pxi b/jnius/jnius_utils.pxi index ef5d6ab9..381d4b05 100644 --- a/jnius/jnius_utils.pxi +++ b/jnius/jnius_utils.pxi @@ -76,7 +76,7 @@ cdef void check_exception(JNIEnv *j_env) except *: j_env[0].DeleteLocalRef(j_env, e_msg) j_env[0].DeleteLocalRef(j_env, exc) - raise JavaException('JVM exception occurred: %s' % (pymsg + " " + str(pyexcclass) if pymsg is not None else pyexcclass), pyexcclass, pymsg, pystack) + raise JavaException('JVM exception occurred: %s' % (str(pyexcclass) + ": " + pymsg if pymsg is not None else pyexcclass), pyexcclass, pymsg, pystack) cdef void _append_exception_trace_messages(