Skip to content

Commit

Permalink
Also catch java exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
fmagin authored and justfoxing committed Nov 18, 2019
1 parent 76450f6 commit 167a43c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ghidra_bridge/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
except NameError: # py3 has no unicode
STRING_TYPES = (str,)

try:
import java.lang.Throwable
except ImportError:
pass


class ThreadingTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
# prevent server threads hanging around and stopping python from closing
Expand Down Expand Up @@ -488,7 +493,7 @@ def serialize_to_dict(self, data):
elif isinstance(data, dict):
serialized_dict = {TYPE: DICT, VALUE: [{KEY: self.serialize_to_dict(
k), VALUE: self.serialize_to_dict(v)} for k, v in data.items()]}
elif isinstance(data, Exception):
elif isinstance(data, Exception) or isinstance(data, java.lang.Throwable):
# treat the exception object as an object
value = self.create_handle(data).to_dict()
# then wrap the exception specifics around it
Expand Down Expand Up @@ -672,6 +677,10 @@ def local_call(self, args_dict):
# don't display StopIteration exceptions, they're totally normal
if not isinstance(e, StopIteration):
traceback.print_exc()
except java.lang.Throwable as t:
self.logger.warning("Got java.long.Throwable: %s" % (t))
result = t


response = self.serialize_to_dict(result)
return response
Expand Down

0 comments on commit 167a43c

Please sign in to comment.