diff options
author | Sven Gothel <[email protected]> | 2021-08-03 12:45:35 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-08-03 12:45:35 +0200 |
commit | 8392b90cef1366730e58c9c38ae10f2408457aed (patch) | |
tree | 24427a377c08b529a236bd15fed6966fabb38a5f /java/jni | |
parent | ee9ebb758c3ed40cc8aaaaa402584a47c89f520a (diff) |
Java JNI: Exceptions: Use jau::RuntimeException derivatives for all exceptions to preserve the backtrace
Diffstat (limited to 'java/jni')
-rw-r--r-- | java/jni/BTUtils.cxx | 4 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/java/jni/BTUtils.cxx b/java/jni/BTUtils.cxx index 18b31e65..526efe74 100644 --- a/java/jni/BTUtils.cxx +++ b/java/jni/BTUtils.cxx @@ -85,7 +85,7 @@ jstring Java_org_direct_1bt_BTUtils_decodeUTF8String(JNIEnv *env, jclass clazz, std::string msg("buffer.length "+std::to_string(buffer_size)+ " < offset "+std::to_string(offset)+ " + size "+std::to_string(size)); - throw std::invalid_argument(msg.c_str()); + throw jau::IllegalArgumentException(msg, E_FILE_LINE); } std::string sres; @@ -93,7 +93,7 @@ jstring Java_org_direct_1bt_BTUtils_decodeUTF8String(JNIEnv *env, jclass clazz, JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release uint8_t * buffer_ptr = criticalArray.get(jbuffer, criticalArray.Mode::NO_UPDATE_AND_RELEASE); if( NULL == buffer_ptr ) { - throw std::invalid_argument("GetPrimitiveArrayCritical(byte array) is null"); + throw jau::IllegalArgumentException("GetPrimitiveArrayCritical(byte array) is null", E_FILE_LINE); } sres = jau::dfa_utf8_decode(buffer_ptr+offset, static_cast<size_t>(size)); } diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index a5ec55a2..1ca51fe5 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -806,7 +806,7 @@ jobject Java_jau_direct_1bt_DBTDevice_getManufacturerData(JNIEnv *env, jobject o result = env->NewObject(map_cls, map_ctor, 0); } if (nullptr == result) { - throw std::bad_alloc(); + throw jau::OutOfMemoryError("new HashMap() returned null", E_FILE_LINE); } return result; } catch(...) { |