Skip to content

Commit

Permalink
Handle Java exceptions thrown in calls from C, printing and aborting
Browse files Browse the repository at this point in the history
Closes #23.
  • Loading branch information
TheBlueMatt committed Jun 23, 2021
1 parent 38853aa commit a2e02c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions java_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@ def native_c_map_trait(self, struct_name, field_vars, flattened_field_vars, fiel
else:
out_c = out_c + ", " + arg_info.arg_name
out_c = out_c + ");\n"

out_c += "\tif ((*env)->ExceptionCheck(env)) {\n"
out_c += "\t\t(*env)->ExceptionDescribe(env);\n"
out_c += "\t\t(*env)->FatalError(env, \"A Java interface method called from rust threw an exception.\");\n"
out_c += "\t}\n"

if fn_line.ret_ty_info.arg_conv is not None:
out_c += "\t" + fn_line.ret_ty_info.arg_conv.replace("\n", "\n\t") + "\n"
out_c += "\t" + self.deconstruct_jenv().replace("\n", "\n\t").strip() + "\n"
Expand Down

0 comments on commit a2e02c9

Please sign in to comment.