Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaException trace #696

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jnius/jnius_export_class.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion jnius/jnius_utils.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading