throwException method
Rethrows Java exception in Dart as JniException.
The original exception object is deleted by this method. The message and Java stack trace are included in the exception.
Implementation
void throwException(JThrowablePtr exception) {
final details = getExceptionDetails(exception);
final env = Jni.env;
final message = env.toDartString(details.message);
final stacktrace = env.toDartString(details.stacktrace);
env.DeleteGlobalRef(exception);
env.DeleteGlobalRef(details.message);
env.DeleteGlobalRef(details.stacktrace);
throw JniException(message, stacktrace);
}