Open tasn opened 4 years ago
Hey,
I'm currently doing something like this to throw custom exceptions:
foreign_typemap!( ($p:r_type) <T> Result<T> => swig_i_type!(T) { $out = match $p { Ok(x) => { swig_from_rust_to_i_type!(T, x, ret) ret } Err(err) => { let msg = err.to_string(); let exception_class = match err { // ... Error::PermissionDenied(_) => swig_jni_find_class!(ETEBASE_PermissionDeniedException, "com/etebase/client/exceptions/PermissionDeniedException"), // ... _ => swig_jni_find_class!(ETEBASE_EtebaseException, "com/etebase/client/exceptions/EtebaseException"), }; jni_throw(env, exception_class, &msg); return <swig_i_type!(T)>::jni_invalid_value(); } }; }; ($p:f_type, unique_prefix="/*etebase::error::Result<swig_subst_type!(T)>*/") => "/*etebase::error::Result<swig_subst_type!(T)>*/swig_f_type!(T)" "swig_foreign_from_i_type!(T, $p)"; );
As you can see, I'm getting the error's string and passing that, and my class to jni_throw. I'd like however to pass the error object itself to Java so that I can have more advanced queries on it. Is it at all possible? If so how do I do it?
jni_throw
Thanks!
Hey,
I'm currently doing something like this to throw custom exceptions:
As you can see, I'm getting the error's string and passing that, and my class to
jni_throw
. I'd like however to pass the error object itself to Java so that I can have more advanced queries on it. Is it at all possible? If so how do I do it?Thanks!