From 4323bd209ea4adce4ec35ee240ea826f677e6be6 Mon Sep 17 00:00:00 2001 From: RGdevz <72873414+RGdevz@users.noreply.github.com> Date: Fri, 6 Sep 2024 04:59:21 +0300 Subject: [PATCH] throw error instead exit (#1323) --- sherpa-onnx/jni/wave-reader.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sherpa-onnx/jni/wave-reader.cc b/sherpa-onnx/jni/wave-reader.cc index a3ca55365..41608c6e0 100644 --- a/sherpa-onnx/jni/wave-reader.cc +++ b/sherpa-onnx/jni/wave-reader.cc @@ -18,7 +18,9 @@ static jobjectArray ReadWaveImpl(JNIEnv *env, std::istream &is, if (!is_ok) { SHERPA_ONNX_LOGE("Failed to read '%s'", p_filename); - exit(-1); + jclass exception_class = env->FindClass("java/lang/Exception"); + env->ThrowNew(exception_class, "Failed to read wave file."); + return nullptr; } jfloatArray samples_arr = env->NewFloatArray(samples.size());