summaryrefslogtreecommitdiffstats
path: root/src/BluetoothGattCharacteristic.cpp
diff options
context:
space:
mode:
authorPetre Eftime <[email protected]>2016-05-10 16:37:33 +0300
committerPetre Eftime <[email protected]>2016-05-10 16:37:33 +0300
commit44ea9ff1da0e10a7e0e8c14167f0fc7e8937bd3a (patch)
tree5b57dcc022a580241f81cfb7f75e896af50a5fb8 /src/BluetoothGattCharacteristic.cpp
parentc07b823b88c35b2e93ca2588afa119c31faf17fe (diff)
java: throw exceptions from JNI to Javav0.4.2
Signed-off-by: Petre Eftime <[email protected]>
Diffstat (limited to 'src/BluetoothGattCharacteristic.cpp')
-rw-r--r--src/BluetoothGattCharacteristic.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/BluetoothGattCharacteristic.cpp b/src/BluetoothGattCharacteristic.cpp
index 9f0867dc..9fb4ca96 100644
--- a/src/BluetoothGattCharacteristic.cpp
+++ b/src/BluetoothGattCharacteristic.cpp
@@ -184,11 +184,11 @@ BluetoothGattService BluetoothGattCharacteristic::get_service ()
NULL,
&error);
- if (service == NULL) {
- g_printerr("Error instantiating: %s",
- error->message);
+ if (service == nullptr) {
+ std::string error_msg("Error occured while instantiating service: ");
+ error_msg += error->message;
g_error_free(error);
- throw std::exception();
+ throw std::runtime_error(error_msg);
}
return BluetoothGattService(service);
@@ -197,7 +197,14 @@ BluetoothGattService BluetoothGattCharacteristic::get_service ()
std::vector<unsigned char> BluetoothGattCharacteristic::get_value ()
{
GBytes *value_gbytes = const_cast<GBytes *>(gatt_characteristic1_get_value (object));
- std::vector<unsigned char> result = from_gbytes_to_vector(value_gbytes);
+ std::vector<unsigned char> result;
+
+ try {
+ result = from_gbytes_to_vector(value_gbytes);
+ } catch (std::exception &e) {
+ g_bytes_unref(value_gbytes);
+ throw e;
+ }
g_bytes_unref(value_gbytes);