From a514fa05fb91cdadc0240678e4663c6de682e4ba Mon Sep 17 00:00:00 2001
From: Giulio Gaio <giulio.gaio@elettra.eu>
Date: Wed, 24 May 2023 21:00:00 +0200
Subject: [PATCH] Added error messages in init device

---
 src/DataVampire.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/DataVampire.cpp b/src/DataVampire.cpp
index cc643c1..ac14883 100644
--- a/src/DataVampire.cpp
+++ b/src/DataVampire.cpp
@@ -281,6 +281,11 @@ void DataVampire::init_device()
     	}	
 	device_name = new_configuration;
 
+	INFO_STREAM << "Command name: " << command_name << endl;
+	INFO_STREAM << "Device name: " << device_name << endl;
+
+	device = 0;
+
 	try {
 		device = new Tango::DeviceProxy(device_name);
 
@@ -291,10 +296,16 @@ void DataVampire::init_device()
 		set_state(Tango::ON);
 		set_status("Connected to device");
 	}	
+	catch (Tango::DevFailed &e) {
+		INFO_STREAM << e.errors[0].desc << ", " << device_name << " " << command_name << endl;
+		INFO_STREAM << e.errors[0].reason << ", " << device_name << " " << command_name << endl;
+		set_state(Tango::FAULT);
+		set_status("Failed to execute device command, check CommandString property and restart device");			
+	}	
 	catch(...) {
 		set_state(Tango::FAULT);
 		set_status("Failed to execute device command, check CommandString property and restart device");
-		printf("Error checking %s\n",new_configuration.c_str());
+		INFO_STREAM << "Generic error, failed to execute command_query on device " << device_name << " " << command_name << endl;
 	}	
 
 	/*
-- 
GitLab