diff options
author | Petre Eftime <[email protected]> | 2016-05-23 17:42:28 +0300 |
---|---|---|
committer | Petre Eftime <[email protected]> | 2016-05-23 18:17:45 +0300 |
commit | 69400113faa7541996c514360e82b355d4f1b102 (patch) | |
tree | 54f4f14e88105340e6e95f6e209d5e252445b674 /src/BluetoothDevice.cpp | |
parent | 85e07cc8be5bf749fef345ac61b53a778d338d06 (diff) |
c++, java: Add BluetoothException, throw it on DBus or BlueZ error
Signed-off-by: Petre Eftime <[email protected]>
Diffstat (limited to 'src/BluetoothDevice.cpp')
-rw-r--r-- | src/BluetoothDevice.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/BluetoothDevice.cpp b/src/BluetoothDevice.cpp index 93fc86e..1b76a84 100644 --- a/src/BluetoothDevice.cpp +++ b/src/BluetoothDevice.cpp @@ -27,6 +27,7 @@ #include "BluetoothDevice.hpp" #include "BluetoothGattService.hpp" #include "BluetoothManager.hpp" +#include "BluetoothException.hpp" using namespace tinyb; @@ -117,8 +118,7 @@ bool BluetoothDevice::disconnect () NULL, &error ); - if (error) - g_printerr("Error: %s\n", error->message); + handle_error(error); return result; } @@ -131,8 +131,7 @@ bool BluetoothDevice::connect () NULL, &error ); - if (error) - g_printerr("Error: %s\n", error->message); + handle_error(error); return result; } @@ -147,8 +146,7 @@ bool BluetoothDevice::connect_profile ( NULL, &error ); - if (error) - g_printerr("Error: %s\n", error->message); + handle_error(error); return result; } @@ -163,8 +161,7 @@ bool BluetoothDevice::disconnect_profile ( NULL, &error ); - if (error) - g_printerr("Error: %s\n", error->message); + handle_error(error); return result; } @@ -177,8 +174,7 @@ bool BluetoothDevice::pair () NULL, &error ); - if (error) - g_printerr("Error: %s\n", error->message); + handle_error(error); return result; } @@ -191,8 +187,7 @@ bool BluetoothDevice::cancel_pairing () NULL, &error ); - if (error) - g_printerr("Error: %s\n", error->message); + handle_error(error); return result; } @@ -314,7 +309,7 @@ BluetoothAdapter BluetoothDevice::get_adapter () std::string error_msg("Error occured while instantiating adapter: "); error_msg += error->message; g_error_free(error); - throw std::runtime_error(error_msg); + throw BluetoothException(error_msg); } return BluetoothAdapter(adapter); |