]> git.bitcoin.ninja Git - ldk-java/commitdiff
Handle Java exceptions thrown in calls from C, printing and aborting v0.0.98.3
authorMatt Corallo <git@bluematt.me>
Tue, 22 Jun 2021 21:55:12 +0000 (21:55 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 23 Jun 2021 00:14:15 +0000 (00:14 +0000)
Closes #23.

java_strings.py

index 7f82567ef408adbb16ab25c58bb0ac857d026cc7..c38d23b2f98725286050903cafe6990b5efb364e 100644 (file)
@@ -854,6 +854,12 @@ import java.util.Arrays;
                     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"