aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-19 02:16:23 +0200
committerSven Gothel <[email protected]>2020-09-19 02:16:23 +0200
commit3139f93409cac61ba5b80caf506375d94eff8778 (patch)
treede4df68d073fab897748785f1ee4647045d49d2f /java
parent5cfe7e13c4dbf07360d928e421050de5e00684a1 (diff)
C++ tinyb/general: Use rethrow_and_raise_java_exception(..) instead of exploded exception case blocks
Diffstat (limited to 'java')
-rw-r--r--java/jni/BluetoothFactory.cxx20
-rw-r--r--java/jni/tinyb/DBusAdapter.cxx420
-rw-r--r--java/jni/tinyb/DBusDevice.cxx612
-rw-r--r--java/jni/tinyb/DBusGattCharacteristic.cxx156
-rw-r--r--java/jni/tinyb/DBusGattDescriptor.cxx120
-rw-r--r--java/jni/tinyb/DBusGattService.cxx84
-rw-r--r--java/jni/tinyb/DBusManager.cxx192
7 files changed, 268 insertions, 1336 deletions
diff --git a/java/jni/BluetoothFactory.cxx b/java/jni/BluetoothFactory.cxx
index 080fef28..f62984cd 100644
--- a/java/jni/BluetoothFactory.cxx
+++ b/java/jni/BluetoothFactory.cxx
@@ -37,14 +37,8 @@ jstring Java_org_tinyb_BluetoothFactory_getNativeAPIVersion(JNIEnv *env, jclass
std::string api_version = std::string(gVERSION_API);
return env->NewStringUTF(api_version.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -63,13 +57,7 @@ void Java_org_tinyb_BluetoothFactory_setenv(JNIEnv *env, jclass clazz, jstring j
setenv(name.c_str(), "true", overwrite);
}
}
- } catch (std::bad_alloc &e) {
- raise_java_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
diff --git a/java/jni/tinyb/DBusAdapter.cxx b/java/jni/tinyb/DBusAdapter.cxx
index 5b676ae2..6e0eda56 100644
--- a/java/jni/tinyb/DBusAdapter.cxx
+++ b/java/jni/tinyb/DBusAdapter.cxx
@@ -39,16 +39,8 @@ jobject Java_tinyb_dbus_DBusAdapter_getBluetoothType(JNIEnv *env, jobject obj)
(void)obj;
return get_bluetooth_type(env, "ADAPTER");
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -57,16 +49,8 @@ jobject Java_tinyb_dbus_DBusAdapter_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothAdapter>(env, obj);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -77,16 +61,8 @@ jboolean Java_tinyb_dbus_DBusAdapter_startDiscovery(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return obj_adapter->start_discovery() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -97,16 +73,8 @@ jboolean Java_tinyb_dbus_DBusAdapter_stopDiscovery(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return obj_adapter->stop_discovery() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -120,16 +88,8 @@ jobject Java_tinyb_dbus_DBusAdapter_getDevices(JNIEnv *env, jobject obj)
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -150,16 +110,8 @@ jint Java_tinyb_dbus_DBusAdapter_removeDevices(JNIEnv *env, jobject obj)
}
return array.size();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -171,16 +123,8 @@ jstring Java_tinyb_dbus_DBusAdapter_getAddress(JNIEnv *env, jobject obj)
std::string address = obj_adapter->get_address();
return env->NewStringUTF((const char *)address.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -192,16 +136,8 @@ jstring Java_tinyb_dbus_DBusAdapter_getName(JNIEnv *env, jobject obj)
std::string name = obj_adapter->get_name();
return env->NewStringUTF((const char *)name.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -213,16 +149,8 @@ jstring Java_tinyb_dbus_DBusAdapter_getAlias(JNIEnv *env, jobject obj)
std::string alias = obj_adapter->get_alias();
return env->NewStringUTF((const char *)alias.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -235,16 +163,8 @@ void Java_tinyb_dbus_DBusAdapter_setAlias(JNIEnv *env, jobject obj, jstring str)
const std::string string_to_write = from_jstring_to_string(env, str);
obj_adapter->set_alias(string_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -254,16 +174,8 @@ jlong Java_tinyb_dbus_DBusAdapter_getBluetoothClass(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return (jlong)obj_adapter->get_class();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -274,16 +186,8 @@ jboolean Java_tinyb_dbus_DBusAdapter_getPowered(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return obj_adapter->get_powered() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -295,16 +199,8 @@ void Java_tinyb_dbus_DBusAdapter_setPowered(JNIEnv *env, jobject obj, jboolean v
bool val_to_write = from_jboolean_to_bool(val);
obj_adapter->set_powered(val_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -330,16 +226,8 @@ void Java_tinyb_dbus_DBusAdapter_enablePoweredNotifications(JNIEnv *env, jobject
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -349,16 +237,8 @@ void Java_tinyb_dbus_DBusAdapter_disablePoweredNotifications(JNIEnv *env, jobjec
BluetoothAdapter *obj_adapter =
getInstance<BluetoothAdapter>(env, obj);
obj_adapter->disable_powered_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -368,16 +248,8 @@ jboolean Java_tinyb_dbus_DBusAdapter_getDiscoverable(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return obj_adapter->get_discoverable() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -389,16 +261,8 @@ void Java_tinyb_dbus_DBusAdapter_setDiscoverable(JNIEnv *env, jobject obj, jbool
bool val_to_write = from_jboolean_to_bool(val);
obj_adapter->set_discoverable(val_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -424,16 +288,8 @@ void Java_tinyb_dbus_DBusAdapter_enableDiscoverableNotifications(JNIEnv *env, jo
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -443,16 +299,8 @@ void Java_tinyb_dbus_DBusAdapter_disableDiscoverableNotifications(JNIEnv *env, j
BluetoothAdapter *obj_adapter =
getInstance<BluetoothAdapter>(env, obj);
obj_adapter->disable_discoverable_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -462,16 +310,8 @@ jlong Java_tinyb_dbus_DBusAdapter_getDiscoverableTimeout(JNIEnv *env, jobject ob
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return (jlong)obj_adapter->get_discoverable_timeout();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -486,16 +326,8 @@ void Java_tinyb_dbus_DBusAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj,
throw std::invalid_argument("timeout argument is negative\n");
}
obj_adapter->set_discoverable_timeout((unsigned int)timeout);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -505,16 +337,8 @@ jboolean Java_tinyb_dbus_DBusAdapter_getPairable(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return obj_adapter->get_pairable() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -541,16 +365,8 @@ void Java_tinyb_dbus_DBusAdapter_enablePairableNotifications(JNIEnv *env, jobjec
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -560,16 +376,8 @@ void Java_tinyb_dbus_DBusAdapter_disablePairableNotifications(JNIEnv *env, jobje
BluetoothAdapter *obj_adapter =
getInstance<BluetoothAdapter>(env, obj);
obj_adapter->disable_pairable_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -580,16 +388,8 @@ void Java_tinyb_dbus_DBusAdapter_setPairable(JNIEnv *env, jobject obj, jboolean
bool val_to_write = from_jboolean_to_bool(val);
obj_adapter->set_pairable(val_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -599,16 +399,8 @@ jlong Java_tinyb_dbus_DBusAdapter_getPairableTimeout(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return (jlong)obj_adapter->get_pairable_timeout();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -623,16 +415,8 @@ void Java_tinyb_dbus_DBusAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jl
throw std::invalid_argument("timeout argument is negative\n");
}
obj_adapter->set_pairable_timeout((unsigned int)timeout);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -642,16 +426,8 @@ jboolean Java_tinyb_dbus_DBusAdapter_getDiscovering(JNIEnv *env, jobject obj)
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
return obj_adapter->get_discovering() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -678,16 +454,8 @@ void Java_tinyb_dbus_DBusAdapter_enableDiscoveringNotifications(JNIEnv *env, job
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -697,16 +465,8 @@ void Java_tinyb_dbus_DBusAdapter_disableDiscoveringNotifications(JNIEnv *env, jo
BluetoothAdapter *obj_adapter =
getInstance<BluetoothAdapter>(env, obj);
obj_adapter->disable_discovering_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -732,16 +492,8 @@ jobjectArray Java_tinyb_dbus_DBusAdapter_getUUIDs(JNIEnv *env, jobject obj)
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -755,16 +507,8 @@ jstring Java_tinyb_dbus_DBusAdapter_getModalias(JNIEnv *env, jobject obj)
return nullptr;
return env->NewStringUTF((const char *)modalias->c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -774,16 +518,8 @@ void Java_tinyb_dbus_DBusAdapter_delete(JNIEnv *env, jobject obj)
try {
BluetoothAdapter *adapter = getInstance<BluetoothAdapter>(env, obj);
delete adapter;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -811,16 +547,8 @@ void Java_tinyb_dbus_DBusAdapter_setDiscoveryFilter(JNIEnv *env, jobject obj, jo
TransportType t_type = from_int_to_transport_type((int) transportType);
obj_adapter->set_discovery_filter(native_uuids, (int16_t) rssi, (uint16_t) pathloss, t_type);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -848,16 +576,8 @@ jobject Java_tinyb_dbus_DBusAdapter_connectDevice(JNIEnv *env, jobject obj, jstr
jobject result = env->NewObject(clazz, clazz_ctor, (jlong)b_device_naked);
fprintf(stderr, "connectDeviceJ.X\n"); fflush(stderr);
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return NULL;
}
diff --git a/java/jni/tinyb/DBusDevice.cxx b/java/jni/tinyb/DBusDevice.cxx
index f810ef9d..c77b2261 100644
--- a/java/jni/tinyb/DBusDevice.cxx
+++ b/java/jni/tinyb/DBusDevice.cxx
@@ -40,16 +40,8 @@ jobject Java_tinyb_dbus_DBusDevice_getBluetoothType(JNIEnv *env, jobject obj)
(void)obj;
return get_bluetooth_type(env, "DEVICE");
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -58,16 +50,8 @@ jobject Java_tinyb_dbus_DBusDevice_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothDevice>(env, obj);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -78,16 +62,8 @@ jboolean Java_tinyb_dbus_DBusDevice_disconnectImpl(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->disconnect() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -98,16 +74,8 @@ void Java_tinyb_dbus_DBusDevice_connectAsyncStart(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
obj_device->connect_async_start();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -117,16 +85,8 @@ jboolean Java_tinyb_dbus_DBusDevice_connectAsyncFinish(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->connect_async_finish() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -137,16 +97,8 @@ jboolean Java_tinyb_dbus_DBusDevice_connectImpl(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->connect() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -159,16 +111,8 @@ jboolean Java_tinyb_dbus_DBusDevice_connectProfile(JNIEnv *env, jobject obj, jst
const std::string string_to_write = from_jstring_to_string(env, str);
return obj_device->connect_profile(string_to_write) ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -181,16 +125,8 @@ jboolean Java_tinyb_dbus_DBusDevice_disconnectProfile(JNIEnv *env, jobject obj,
const std::string string_to_write = from_jstring_to_string(env, str);
return obj_device->disconnect_profile(string_to_write) ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -201,16 +137,8 @@ jboolean Java_tinyb_dbus_DBusDevice_pair(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->pair() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -221,16 +149,8 @@ jboolean Java_tinyb_dbus_DBusDevice_remove(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->remove_device() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -241,16 +161,8 @@ jboolean Java_tinyb_dbus_DBusDevice_cancelPairing(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->cancel_pairing() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -264,16 +176,8 @@ jobject Java_tinyb_dbus_DBusDevice_getServices(JNIEnv *env, jobject obj)
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -285,16 +189,8 @@ jstring Java_tinyb_dbus_DBusDevice_getAddress(JNIEnv *env, jobject obj)
std::string address = obj_device->get_address();
return env->NewStringUTF((const char *)address.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -306,16 +202,8 @@ jstring Java_tinyb_dbus_DBusDevice_getName(JNIEnv *env, jobject obj)
std::string name = obj_device->get_name();
return env->NewStringUTF((const char *)name.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -327,16 +215,8 @@ jstring Java_tinyb_dbus_DBusDevice_getAlias(JNIEnv *env, jobject obj)
std::string alias = obj_device->get_alias();
return env->NewStringUTF((const char *)alias.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -349,16 +229,8 @@ void Java_tinyb_dbus_DBusDevice_setAlias(JNIEnv *env, jobject obj, jstring str)
const std::string string_to_write = from_jstring_to_string(env, str);
obj_device->set_alias(string_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -368,16 +240,8 @@ jint Java_tinyb_dbus_DBusDevice_getBluetoothClass(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return (jlong)obj_device->get_class();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -388,16 +252,8 @@ jshort Java_tinyb_dbus_DBusDevice_getAppearance(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return (jshort)obj_device->get_appearance();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -411,16 +267,8 @@ jstring Java_tinyb_dbus_DBusDevice_getIcon(JNIEnv *env, jobject obj)
return nullptr;
return env->NewStringUTF((const char *)icon->c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -431,16 +279,8 @@ jboolean Java_tinyb_dbus_DBusDevice_getPaired(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->get_paired() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -467,16 +307,8 @@ void Java_tinyb_dbus_DBusDevice_enablePairedNotifications(JNIEnv *env, jobject o
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -486,16 +318,8 @@ void Java_tinyb_dbus_DBusDevice_disablePairedNotifications(JNIEnv *env, jobject
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_paired_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -505,16 +329,8 @@ jboolean Java_tinyb_dbus_DBusDevice_getTrusted(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->get_trusted() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -526,16 +342,8 @@ void Java_tinyb_dbus_DBusDevice_setTrusted(JNIEnv *env, jobject obj, jboolean va
bool val_to_write = from_jboolean_to_bool(val);
obj_device->set_trusted(val_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -561,16 +369,8 @@ void Java_tinyb_dbus_DBusDevice_enableTrustedNotifications(JNIEnv *env, jobject
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -580,16 +380,8 @@ void Java_tinyb_dbus_DBusDevice_disableTrustedNotifications(JNIEnv *env, jobject
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_trusted_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -599,16 +391,8 @@ jboolean Java_tinyb_dbus_DBusDevice_getBlocked(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->get_blocked() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -620,16 +404,8 @@ void Java_tinyb_dbus_DBusDevice_setBlocked(JNIEnv *env, jobject obj, jboolean va
bool val_to_write = from_jboolean_to_bool(val);
obj_device->set_blocked(val_to_write);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -655,16 +431,8 @@ void Java_tinyb_dbus_DBusDevice_enableBlockedNotifications(JNIEnv *env, jobject
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -674,16 +442,8 @@ void Java_tinyb_dbus_DBusDevice_disableBlockedNotifications(JNIEnv *env, jobject
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_blocked_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -693,16 +453,8 @@ jboolean Java_tinyb_dbus_DBusDevice_getLegacyPairing(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->get_legacy_pairing() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -713,16 +465,8 @@ jshort Java_tinyb_dbus_DBusDevice_getRSSI(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return (jshort)obj_device->get_rssi();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -749,16 +493,8 @@ void Java_tinyb_dbus_DBusDevice_enableRSSINotifications(JNIEnv *env, jobject obj
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -768,16 +504,8 @@ void Java_tinyb_dbus_DBusDevice_disableRSSINotifications(JNIEnv *env, jobject ob
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_rssi_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -787,16 +515,8 @@ jboolean Java_tinyb_dbus_DBusDevice_getConnected(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->get_connected() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -823,16 +543,8 @@ void Java_tinyb_dbus_DBusDevice_enableConnectedNotifications(JNIEnv *env, jobjec
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -842,16 +554,8 @@ void Java_tinyb_dbus_DBusDevice_disableConnectedNotifications(JNIEnv *env, jobje
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_connected_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -873,16 +577,8 @@ jobjectArray Java_tinyb_dbus_DBusDevice_getUUIDs(JNIEnv *env, jobject obj)
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -896,16 +592,8 @@ jstring Java_tinyb_dbus_DBusDevice_getModalias(JNIEnv *env, jobject obj)
return nullptr;
return env->NewStringUTF((const char *)modalias->c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -926,16 +614,8 @@ jobject Java_tinyb_dbus_DBusDevice_getAdapter(JNIEnv *env, jobject obj)
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -975,16 +655,8 @@ jobject Java_tinyb_dbus_DBusDevice_getManufacturerData(JNIEnv *env, jobject obj)
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -1029,16 +701,8 @@ void Java_tinyb_dbus_DBusDevice_enableManufacturerDataNotifications(JNIEnv *env,
jni_env->DeleteLocalRef(short_cls);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -1048,16 +712,8 @@ void Java_tinyb_dbus_DBusDevice_disableManufacturerDataNotifications(JNIEnv *env
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_service_data_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -1092,16 +748,8 @@ jobject Java_tinyb_dbus_DBusDevice_getServiceData(JNIEnv *env, jobject obj)
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -1141,16 +789,8 @@ void Java_tinyb_dbus_DBusDevice_enableServiceDataNotifications(JNIEnv *env, jobj
jni_env->CallVoidMethod(**callback_ptr, method, result);
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -1160,16 +800,8 @@ void Java_tinyb_dbus_DBusDevice_disableServiceDataNotifications(JNIEnv *env, job
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_service_data_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -1181,16 +813,8 @@ jshort Java_tinyb_dbus_DBusDevice_getTxPower(JNIEnv *env, jobject obj)
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return (jshort)obj_device->get_tx_power();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return 0;
}
@@ -1201,16 +825,8 @@ jboolean Java_tinyb_dbus_DBusDevice_getServicesResolved(JNIEnv *env, jobject obj
BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj);
return obj_device->get_services_resolved() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -1237,16 +853,8 @@ void Java_tinyb_dbus_DBusDevice_enableServicesResolvedNotifications(JNIEnv *env,
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -1256,16 +864,8 @@ void Java_tinyb_dbus_DBusDevice_disableServicesResolvedNotifications(JNIEnv *env
BluetoothDevice *obj_device =
getInstance<BluetoothDevice>(env, obj);
obj_device->disable_services_resolved_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -1276,16 +876,8 @@ void Java_tinyb_dbus_DBusDevice_delete(JNIEnv *env, jobject obj)
try {
BluetoothDevice *b_device = getInstance<BluetoothDevice>(env, obj);
delete b_device;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
diff --git a/java/jni/tinyb/DBusGattCharacteristic.cxx b/java/jni/tinyb/DBusGattCharacteristic.cxx
index d6b7ae14..781ec299 100644
--- a/java/jni/tinyb/DBusGattCharacteristic.cxx
+++ b/java/jni/tinyb/DBusGattCharacteristic.cxx
@@ -40,16 +40,8 @@ jobject Java_tinyb_dbus_DBusGattCharacteristic_getBluetoothType(JNIEnv *env, job
(void)obj;
return get_bluetooth_type(env, "GATT_CHARACTERISTIC");
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -58,16 +50,8 @@ jobject Java_tinyb_dbus_DBusGattCharacteristic_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothGattCharacteristic>(env, obj);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -84,16 +68,8 @@ jbyteArray Java_tinyb_dbus_DBusGattCharacteristic_readValue(JNIEnv *env, jobject
env->SetByteArrayRegion(result, 0, (jsize)array_size, (const jbyte *)&array[0]);
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -117,16 +93,8 @@ jboolean Java_tinyb_dbus_DBusGattCharacteristic_writeValue(JNIEnv *env, jobject
std::vector<unsigned char> array(native_array, native_array + native_array_length);
return obj_gatt_char->write_value(array) ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -151,16 +119,8 @@ void Java_tinyb_dbus_DBusGattCharacteristic_enableValueNotifications(JNIEnv *env
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -170,16 +130,8 @@ void Java_tinyb_dbus_DBusGattCharacteristic_disableValueNotifications(JNIEnv *en
BluetoothGattCharacteristic *obj_gatt_char =
getInstance<BluetoothGattCharacteristic>(env, obj);
obj_gatt_char->disable_value_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -191,16 +143,8 @@ jstring Java_tinyb_dbus_DBusGattCharacteristic_getUUID(JNIEnv *env, jobject obj)
std::string uuid = obj_gatt_char->get_uuid();
return env->NewStringUTF((const char *)uuid.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -222,16 +166,8 @@ jobject Java_tinyb_dbus_DBusGattCharacteristic_getService(JNIEnv *env, jobject o
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -248,16 +184,8 @@ jbyteArray Java_tinyb_dbus_DBusGattCharacteristic_getValue(JNIEnv *env, jobject
env->SetByteArrayRegion(result, 0, (jsize)array_size, (const jbyte *)&array[0]);
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -268,16 +196,8 @@ jboolean Java_tinyb_dbus_DBusGattCharacteristic_getNotifying(JNIEnv *env, jobjec
BluetoothGattCharacteristic *obj_gatt_char =
getInstance<BluetoothGattCharacteristic>(env, obj);
return obj_gatt_char->get_notifying() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -301,16 +221,8 @@ jobjectArray Java_tinyb_dbus_DBusGattCharacteristic_getFlags(JNIEnv *env, jobjec
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -325,16 +237,8 @@ jobject Java_tinyb_dbus_DBusGattCharacteristic_getDescriptors(JNIEnv *env, jobje
jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattDescriptor>(env, array,
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -345,15 +249,7 @@ void Java_tinyb_dbus_DBusGattCharacteristic_delete(JNIEnv *env, jobject obj)
BluetoothGattCharacteristic *obj_gatt_char =
getInstance<BluetoothGattCharacteristic>(env, obj);
delete obj_gatt_char;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
diff --git a/java/jni/tinyb/DBusGattDescriptor.cxx b/java/jni/tinyb/DBusGattDescriptor.cxx
index 2118205c..d6af712f 100644
--- a/java/jni/tinyb/DBusGattDescriptor.cxx
+++ b/java/jni/tinyb/DBusGattDescriptor.cxx
@@ -39,16 +39,8 @@ jobject Java_tinyb_dbus_DBusGattDescriptor_getBluetoothType(JNIEnv *env, jobject
(void)obj;
return get_bluetooth_type(env, "GATT_DESCRIPTOR");
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -57,16 +49,8 @@ jobject Java_tinyb_dbus_DBusGattDescriptor_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothGattDescriptor>(env, obj);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -82,16 +66,8 @@ jbyteArray Java_tinyb_dbus_DBusGattDescriptor_readValue(JNIEnv *env, jobject obj
env->SetByteArrayRegion(result, 0, (jsize)array_size, (const jbyte *)&array[0]);
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -113,16 +89,8 @@ jboolean Java_tinyb_dbus_DBusGattDescriptor_writeValue(JNIEnv *env, jobject obj,
std::vector<unsigned char> array(native_array, native_array + native_array_length);
return obj_gatt_desc->write_value(array) ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -134,16 +102,8 @@ jstring Java_tinyb_dbus_DBusGattDescriptor_getUUID(JNIEnv *env, jobject obj)
std::string uuid = obj_gatt_desc->get_uuid();
return env->NewStringUTF((const char *)uuid.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -164,16 +124,8 @@ jobject Java_tinyb_dbus_DBusGattDescriptor_getCharacteristic(JNIEnv *env, jobjec
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -190,16 +142,8 @@ jbyteArray Java_tinyb_dbus_DBusGattDescriptor_getValue(JNIEnv *env, jobject obj)
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -224,16 +168,8 @@ void Java_tinyb_dbus_DBusGattDescriptor_enableValueNotifications(JNIEnv *env, jo
jni_env->DeleteLocalRef(result);
});
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -243,16 +179,8 @@ void Java_tinyb_dbus_DBusGattDescriptor_disableValueNotifications(JNIEnv *env, j
BluetoothGattDescriptor *obj_gatt_desc =
getInstance<BluetoothGattDescriptor>(env, obj);
obj_gatt_desc->disable_value_notifications();
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -262,16 +190,8 @@ void Java_tinyb_dbus_DBusGattDescriptor_delete(JNIEnv *env, jobject obj)
try {
BluetoothGattDescriptor *obj_gatt_desc = getInstance<BluetoothGattDescriptor>(env, obj);
delete obj_gatt_desc;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
diff --git a/java/jni/tinyb/DBusGattService.cxx b/java/jni/tinyb/DBusGattService.cxx
index 8e94cec8..a9101516 100644
--- a/java/jni/tinyb/DBusGattService.cxx
+++ b/java/jni/tinyb/DBusGattService.cxx
@@ -39,16 +39,8 @@ jobject Java_tinyb_dbus_DBusGattService_getBluetoothType(JNIEnv *env, jobject ob
(void)obj;
return get_bluetooth_type(env, "GATT_SERVICE");
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -57,16 +49,8 @@ jobject Java_tinyb_dbus_DBusGattService_clone(JNIEnv *env, jobject obj)
{
try {
return generic_clone<BluetoothGattService>(env, obj);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -78,16 +62,8 @@ jstring Java_tinyb_dbus_DBusGattService_getUUID(JNIEnv *env, jobject obj)
std::string uuid = obj_gatt_serv->get_uuid();
return env->NewStringUTF((const char *)uuid.c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -108,16 +84,8 @@ jobject Java_tinyb_dbus_DBusGattService_getDevice(JNIEnv *env, jobject obj)
}
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -128,16 +96,8 @@ jboolean Java_tinyb_dbus_DBusGattService_getPrimary(JNIEnv *env, jobject obj)
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
return obj_gatt_serv->get_primary() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -151,16 +111,8 @@ jobject Java_tinyb_dbus_DBusGattService_getCharacteristics(JNIEnv *env, jobject
jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattCharacteristic>(env, array,
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -170,16 +122,8 @@ void Java_tinyb_dbus_DBusGattService_delete(JNIEnv *env, jobject obj)
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
delete obj_gatt_serv;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
diff --git a/java/jni/tinyb/DBusManager.cxx b/java/jni/tinyb/DBusManager.cxx
index 2919d28e..28150a13 100644
--- a/java/jni/tinyb/DBusManager.cxx
+++ b/java/jni/tinyb/DBusManager.cxx
@@ -39,16 +39,8 @@ jobject Java_tinyb_dbus_DBusManager_getBluetoothType(JNIEnv *env, jobject obj)
(void)obj;
return get_bluetooth_type(env, "NONE");
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -85,16 +77,8 @@ static void getObject_setter(JNIEnv *env,
{
*identifier_to_write = new std::string(from_jstring_to_string(env, identifier));
}
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -142,16 +126,8 @@ jobject Java_tinyb_dbus_DBusManager_find(JNIEnv *env, jobject obj, jint type,
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -188,16 +164,8 @@ jobject Java_tinyb_dbus_DBusManager_getObject(JNIEnv *env, jobject obj, jint typ
jobject result = env->NewObject(clazz, clazz_ctor, (jlong)b_object_naked);
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -225,16 +193,8 @@ jobject Java_tinyb_dbus_DBusManager_getObjects(JNIEnv *env, jobject obj, jint ty
getObject_cleaner(name_to_write, identifier_to_write);
jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothObject>(env, array, "(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -248,16 +208,8 @@ jobject Java_tinyb_dbus_DBusManager_getAdapters(JNIEnv *env, jobject obj)
jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothAdapter>(env, array,
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -271,16 +223,8 @@ jobject Java_tinyb_dbus_DBusManager_getDevices(JNIEnv *env, jobject obj)
jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothDevice>(env, array,
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -294,16 +238,8 @@ jobject Java_tinyb_dbus_DBusManager_getServices(JNIEnv *env, jobject obj)
jobject result = convert_vector_uniqueptr_to_jarraylist<BluetoothGattService>(env, array,
"(J)V");
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}
@@ -318,16 +254,8 @@ jboolean Java_tinyb_dbus_DBusManager_setDefaultAdapter(JNIEnv *env, jobject obj,
BluetoothAdapter *b_adapter = getInstance<BluetoothAdapter>(env, adapter);
return manager->set_default_adapter(*b_adapter);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -348,16 +276,8 @@ jobject Java_tinyb_dbus_DBusManager_getDefaultAdapter(JNIEnv *env, jobject obj)
jobject result = env->NewObject(clazz, clazz_ctor, (jlong)b_adapter_naked);
return result;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return NULL;
}
@@ -367,16 +287,8 @@ jboolean Java_tinyb_dbus_DBusManager_startDiscovery(JNIEnv *env, jobject obj)
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
return manager->start_discovery() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -386,16 +298,8 @@ jboolean Java_tinyb_dbus_DBusManager_stopDiscovery(JNIEnv *env, jobject obj)
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
return manager->start_discovery() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -405,16 +309,8 @@ jboolean Java_tinyb_dbus_DBusManager_getDiscovering(JNIEnv *env, jobject obj)
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
return manager->get_discovering() ? JNI_TRUE : JNI_FALSE;
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return JNI_FALSE;
}
@@ -424,16 +320,8 @@ void Java_tinyb_dbus_DBusManager_init(JNIEnv *env, jobject obj)
try {
BluetoothManager *manager = BluetoothManager::get_bluetooth_manager();
setInstance<BluetoothManager>(env, obj, manager);
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -443,16 +331,8 @@ void Java_tinyb_dbus_DBusManager_delete(JNIEnv *env, jobject obj)
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
(void) manager;
// delete manager; // Should not be called!
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
}
@@ -463,16 +343,8 @@ jstring Java_tinyb_dbus_DBusManager_getNativeAPIVersion(JNIEnv *env, jclass claz
BluetoothManager *manager = BluetoothManager::get_bluetooth_manager();
return env->NewStringUTF(manager->get_api_version().c_str());
- } catch (std::bad_alloc &e) {
- raise_java_oom_exception(env, e);
- } catch (BluetoothException &e) {
- raise_java_bluetooth_exception(env, e);
- } catch (std::runtime_error &e) {
- raise_java_runtime_exception(env, e);
- } catch (std::invalid_argument &e) {
- raise_java_invalid_arg_exception(env, e);
- } catch (std::exception &e) {
- raise_java_exception(env, e);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
}
return nullptr;
}