(
env: &'b JNIEnv<'a>,
result: JPollResult<'a, 'b>,
)
| 52 | } |
| 53 | |
| 54 | fn get_poll_result<'a: 'b, 'b>( |
| 55 | env: &'b JNIEnv<'a>, |
| 56 | result: JPollResult<'a, 'b>, |
| 57 | ) -> Result<JObject<'a>> { |
| 58 | try_block(env, || Ok(Ok(result.get()?))) |
| 59 | .catch( |
| 60 | JClass::from( |
| 61 | super::jni_utils::classcache::get_class( |
| 62 | "io/github/gedgygedgy/rust/future/FutureException", |
| 63 | ) |
| 64 | .unwrap() |
| 65 | .as_obj(), |
| 66 | ), |
| 67 | |ex| { |
| 68 | let cause = env |
| 69 | .call_method(ex, "getCause", "()Ljava/lang/Throwable;", &[])? |
| 70 | .l()?; |
| 71 | if env.is_instance_of( |
| 72 | cause, |
| 73 | JClass::from( |
| 74 | super::jni_utils::classcache::get_class( |
| 75 | "com/nonpolynomial/btleplug/android/impl/NotConnectedException", |
| 76 | ) |
| 77 | .unwrap() |
| 78 | .as_obj(), |
| 79 | ), |
| 80 | )? { |
| 81 | Ok(Err(Error::NotConnected)) |
| 82 | } else if env.is_instance_of( |
| 83 | cause, |
| 84 | JClass::from( |
| 85 | super::jni_utils::classcache::get_class( |
| 86 | "com/nonpolynomial/btleplug/android/impl/PermissionDeniedException", |
| 87 | ) |
| 88 | .unwrap() |
| 89 | .as_obj(), |
| 90 | ), |
| 91 | )? { |
| 92 | Ok(Err(Error::PermissionDenied)) |
| 93 | } else if env.is_instance_of( |
| 94 | cause, |
| 95 | JClass::from( |
| 96 | super::jni_utils::classcache::get_class( |
| 97 | "com/nonpolynomial/btleplug/android/impl/UnexpectedCallbackException", |
| 98 | ) |
| 99 | .unwrap() |
| 100 | .as_obj(), |
| 101 | ), |
| 102 | )? { |
| 103 | Ok(Err(Error::UnexpectedCallback)) |
| 104 | } else if env.is_instance_of( |
| 105 | cause, |
| 106 | JClass::from( |
| 107 | super::jni_utils::classcache::get_class( |
| 108 | "com/nonpolynomial/btleplug/android/impl/UnexpectedCharacteristicException", |
| 109 | ) |
| 110 | .unwrap() |
| 111 | .as_obj(), |
no test coverage detected