* Static function to throw the exception if one exists within the ENV. * @param env Requires an environment to check */
| 88 | * @param env Requires an environment to check |
| 89 | */ |
| 90 | static inline void ThrowIf(JNIEnv *env) { |
| 91 | jthrowable throwable = env->ExceptionOccurred(); |
| 92 | if (UNLIKELY(throwable != nullptr)) { // we have faith maybe it won't happen! |
| 93 | env->ExceptionClear(); |
| 94 | auto message = getMessage(env, throwable); |
| 95 | env->ThrowNew(env->FindClass(EXCEPTION_CLASS), message.c_str()); |
| 96 | throw JavaException(message); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | static inline void ThrowJava(JNIEnv *env, const char *message) { |
| 101 | env->ExceptionClear(); |
no test coverage detected