Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 9535ad1

Browse files
author
Ingvord
authored
Fix #453: replace assert with exception (#454)
Close #453
1 parent f60f534 commit 9535ad1

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

RELEASE_NOTES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[Unreleased]
1+
9.3.1 [UNRELEASED]
22
============
33

44
1. Add -pedantic for GCC/Clang and debug mode (#441). This change can generate
@@ -12,6 +12,7 @@
1212
6. EventConsumer::connect_event: Fix misleading indentation (#441)
1313
7. PollThread: Fix multiline macro definitions (#451)
1414
8. Generate static library (#17) and fix compilation definitions (#437)
15+
9. Replace asserts in EventConsumer::initialize_received_from_admin with exceptions (#453)
1516

1617
9.3.0
1718
=====

cppapi/client/event.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,14 +1837,21 @@ void Tango::EventConsumer::initialize_received_from_admin(const Tango::DevVarLon
18371837
const string &adm_name,
18381838
bool device_from_env_var)
18391839
{
1840+
if(dvlsa->lvalue.length() == 0)
1841+
{
1842+
EventSystemExcept::throw_exception(API_NotSupported,
1843+
"Server did not send its tango lib version. The server is possibly too old. The event system is not initialized!",
1844+
"EventConsumer::initialize_received_from_admin()");
1845+
}
1846+
18401847
long server_tango_lib_ver = dvlsa->lvalue[0];
18411848

18421849
//event name is used for zmq topics filtering
18431850
//channel name is used for heartbeat events
18441851
if (server_tango_lib_ver >= 930)
18451852
{
18461853
received_from_admin.event_name = (dvlsa->svalue[dvlsa->svalue.length() - 2]);
1847-
received_from_admin.channel_name = (dvlsa->svalue[dvlsa->svalue.length() - 1]);
1854+
received_from_admin.channel_name = (dvlsa->svalue[dvlsa->svalue.length() - 1]);
18481855
}
18491856
else
18501857
{
@@ -1860,9 +1867,21 @@ void Tango::EventConsumer::initialize_received_from_admin(const Tango::DevVarLon
18601867
received_from_admin.channel_name = adm_name_lower;
18611868
}
18621869

1863-
assert(!(received_from_admin.event_name.empty()));
1870+
if (received_from_admin.event_name.empty())
1871+
{
1872+
EventSystemExcept::throw_exception(API_NotSupported,
1873+
"Server did not send the event name. The server is possibly too old. The event system is not initialized!",
1874+
"EventConsumer::initialize_received_from_admin()");
1875+
1876+
}
1877+
18641878
cout4 << "received_from_admin.event_name = " << received_from_admin.event_name << endl;
1865-
assert(!(received_from_admin.channel_name.empty()));
1879+
if (received_from_admin.channel_name.empty())
1880+
{
1881+
EventSystemExcept::throw_exception(API_NotSupported,
1882+
"Server did not send the channel name. The server is possibly too old. The event system is not initialized!",
1883+
"EventConsumer::initialize_received_from_admin()");
1884+
}
18661885
cout4 << "received_from_admin.channel_name = " << received_from_admin.channel_name << endl;
18671886
}
18681887

0 commit comments

Comments
 (0)