Add exception utilities to the crate

This commit is contained in:
Jack Grigg 2019-02-11 16:35:25 +00:00
parent 37c0efad77
commit 42b2076dc1
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
2 changed files with 4 additions and 5 deletions

View File

@ -7,6 +7,8 @@ use jni::{
};
use std::ops::Deref;
pub(crate) mod exception;
pub(crate) fn java_string_to_rust(env: &JNIEnv<'_>, jstring: JString<'_>) -> String {
env.get_string(jstring)
.expect("Couldn't get Java string!")

View File

@ -12,16 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use jni::JNIEnv;
use jni::{errors::Result as JniResult, JNIEnv};
use std::any::Any;
use std::error::Error;
use std::result;
use std::thread;
use JniError;
type ExceptionResult<T> = thread::Result<result::Result<T, JniError>>;
type ExceptionResult<T> = thread::Result<JniResult<T>>;
// Returns value or "throws" exception. `error_val` is returned, because exception will be thrown
// at the Java side. So this function should be used only for the `panic::catch_unwind` result.