Attempt to execute a block of JNI code. If the code causes an exception to be thrown, it will be stored in the resulting [`TryCatchResult`] for matching with [`catch`](TryCatchResult::catch).
(
env: &'b JNIEnv<'a>,
block: impl FnOnce() -> Result<T, Error>,
)
| 23 | /// to be thrown, it will be stored in the resulting [`TryCatchResult`] for |
| 24 | /// matching with [`catch`](TryCatchResult::catch). |
| 25 | pub fn try_block<'a: 'b, 'b, T>( |
| 26 | env: &'b JNIEnv<'a>, |
| 27 | block: impl FnOnce() -> Result<T, Error>, |
| 28 | ) -> TryCatchResult<'a, 'b, T> { |
| 29 | TryCatchResult { |
| 30 | env, |
| 31 | try_result: (|| { |
| 32 | if env.exception_check()? { |
| 33 | Err(Error::JavaException) |
| 34 | } else { |
| 35 | Ok(block()) |
| 36 | } |
| 37 | })(), |
| 38 | catch_result: None, |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | impl<'a: 'b, 'b, T> TryCatchResult<'a, 'b, T> { |
| 43 | pub fn catch( |
no outgoing calls