RGdevz
Committed by GitHub

throw error instead exit (#1323)

@@ -18,7 +18,9 @@ static jobjectArray ReadWaveImpl(JNIEnv *env, std::istream &is, @@ -18,7 +18,9 @@ static jobjectArray ReadWaveImpl(JNIEnv *env, std::istream &is,
18 18
19 if (!is_ok) { 19 if (!is_ok) {
20 SHERPA_ONNX_LOGE("Failed to read '%s'", p_filename); 20 SHERPA_ONNX_LOGE("Failed to read '%s'", p_filename);
21 - exit(-1); 21 + jclass exception_class = env->FindClass("java/lang/Exception");
  22 + env->ThrowNew(exception_class, "Failed to read wave file.");
  23 + return nullptr;
22 } 24 }
23 25
24 jfloatArray samples_arr = env->NewFloatArray(samples.size()); 26 jfloatArray samples_arr = env->NewFloatArray(samples.size());