| 248 | } |
| 249 | |
| 250 | static djinni::LocalRef<jobject> newValdiException(JavaEnv env, const Valdi::Error& error) { |
| 251 | auto convertedMessage = toJavaObject(env, error.getMessage()); |
| 252 | // Carry the code when there is one, so a cancellation stays distinguishable from a genuine |
| 253 | // failure on the Kotlin side (see Throwable.valdiErrorCode) instead of only the message |
| 254 | // surviving. Errors without a code keep using the message-only constructor. |
| 255 | const auto errorCode = error.getErrorCode(); |
| 256 | if (errorCode != 0) { |
| 257 | return JavaEnv::getCache().getValdiExceptionClass().newObject( |
no test coverage detected