summaryrefslogtreecommitdiffstats
path: root/examples/hellotinyb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hellotinyb.cpp')
-rw-r--r--examples/hellotinyb.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/hellotinyb.cpp b/examples/hellotinyb.cpp
index 59246c83..549b568c 100644
--- a/examples/hellotinyb.cpp
+++ b/examples/hellotinyb.cpp
@@ -46,13 +46,19 @@ static float celsius_temp(uint16_t raw_temp)
*/
int main(int argc, char **argv)
{
- BluetoothManager *manager = BluetoothManager::get_bluetooth_manager();
-
if (argc < 2) {
std::cerr << "Run as: " << argv[0] << " <device_address>" << std::endl;
exit(1);
}
+ BluetoothManager *manager = nullptr;
+ try {
+ manager = BluetoothManager::get_bluetooth_manager();
+ } catch(const std::runtime_error& e) {
+ std::cerr << "Error while initializing libtinyb: " << e.what() << std::endl;
+ exit(1);
+ }
+
/* Start the discovery of devices */
bool ret = manager->start_discovery();
std::cout << "Started = " << (ret ? "true" : "false") << std::endl;