mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
JavaClassWrapper: Allow handling exceptions (rather than just crashing)
This commit is contained in:
parent
b607110ad2
commit
5d69d20059
4 changed files with 29 additions and 0 deletions
|
@ -517,6 +517,20 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method,
|
|||
env->DeleteLocalRef(E);
|
||||
}
|
||||
|
||||
jobject exception = env->ExceptionOccurred();
|
||||
if (exception) {
|
||||
env->ExceptionClear();
|
||||
|
||||
jclass java_class = env->GetObjectClass(exception);
|
||||
Ref<JavaClass> java_class_wrapped = JavaClassWrapper::singleton->wrap_jclass(java_class);
|
||||
env->DeleteLocalRef(java_class);
|
||||
|
||||
JavaClassWrapper::singleton->exception.instantiate(java_class_wrapped, exception);
|
||||
env->DeleteLocalRef(exception);
|
||||
} else {
|
||||
JavaClassWrapper::singleton->exception.unref();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue