Kotlin: Throw exception when Dawn methods return non-OK status.
Bug: 357826002
Change-Id: I08c69fc268788036b19d561b6edc1d801a910d28
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/201496
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jim Blackler <jimblackler@google.com>
diff --git a/generator/templates/art/methods.cpp b/generator/templates/art/methods.cpp
index 770e797..2334882 100644
--- a/generator/templates/art/methods.cpp
+++ b/generator/templates/art/methods.cpp
@@ -159,6 +159,13 @@
if (env->ExceptionCheck()) { //* Early out if client (Kotlin) callback threw an exception.
return {{ '0' if method.return_type.name.get() != 'void' }};
}
+ {% if method.return_type.name.canonical_case() == 'status' %}
+ if (result != WGPUStatus_Success) {
+ //* TODO(b/344805524): custom exception for Dawn.
+ env->ThrowNew(env->FindClass("java/lang/Error"), "Method failed");
+ return {{ '0' if method.return_type.name.get() != 'void' }};
+ }
+ {% endif %}
{% endif %}
{% if _kotlin_return.type.name.get() != 'void' %}
{% if _kotlin_return.type.name.get() in ['void const *', 'void *'] %}