Replies: 1 comment 1 reply
-
The Generator doesn't support custom exceptions like that. It assumes by default it's going to get std::exception and throws a RuntimeException with the string from the what() function, but we can change that by defining the GENERIC_EXCEPTION_CLASS and GENERIC_EXCEPTION_TOSTRING macros: |
Beta Was this translation helpful? Give feedback.
-
I'm continuing to try and convert a large code base from swig to javacpp. We have lots of custom C++ exceptions that can be thrown. I have seamingly failed at figuring out how to handle them in my javacpp preset I'm working on.
here is a sample of the c++ definition of the exception:
I have tried various mappings and even javaText to get the results I wanted
infoMap.put(new Info("toplevel::component::MyException").skipDefaults().base("Exception"));
but in the end I was hoping to generate something like this
on the other end, if I'm interpreting the jni code correctly, the exception handling is done in the following routine:
I thought it was appropriate to modify it as follow to pass my exception:
Is my approach to using custom exceptions correct?
Since the java exception is never actually used in the c++ code. Does it make sense to not have it based off of Pointer?
Is there a way for the presets to generate simple class code not based on Pointer?
Is there a way through comments or depreciated methods exception declaration in the c++ code that is being parsed to add the exception handling in c++? Similar to my example to JavaCPP_handleException?
Could I extend parser to handle these conditions?
Beta Was this translation helpful? Give feedback.
All reactions