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

Commit

Permalink
Fix #453: replace assert with exception (#454)
Browse files Browse the repository at this point in the history
Close #453
  • Loading branch information
Ingvord authored May 23, 2018
1 parent f60f534 commit 9535ad1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion RELEASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Unreleased]
9.3.1 [UNRELEASED]
============

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

9.3.0
=====
Expand Down
25 changes: 22 additions & 3 deletions cppapi/client/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1837,14 +1837,21 @@ void Tango::EventConsumer::initialize_received_from_admin(const Tango::DevVarLon
const string &adm_name,
bool device_from_env_var)
{
if(dvlsa->lvalue.length() == 0)
{
EventSystemExcept::throw_exception(API_NotSupported,
"Server did not send its tango lib version. The server is possibly too old. The event system is not initialized!",
"EventConsumer::initialize_received_from_admin()");
}

long server_tango_lib_ver = dvlsa->lvalue[0];

//event name is used for zmq topics filtering
//channel name is used for heartbeat events
if (server_tango_lib_ver >= 930)
{
received_from_admin.event_name = (dvlsa->svalue[dvlsa->svalue.length() - 2]);
received_from_admin.channel_name = (dvlsa->svalue[dvlsa->svalue.length() - 1]);
received_from_admin.channel_name = (dvlsa->svalue[dvlsa->svalue.length() - 1]);
}
else
{
Expand All @@ -1860,9 +1867,21 @@ void Tango::EventConsumer::initialize_received_from_admin(const Tango::DevVarLon
received_from_admin.channel_name = adm_name_lower;
}

assert(!(received_from_admin.event_name.empty()));
if (received_from_admin.event_name.empty())
{
EventSystemExcept::throw_exception(API_NotSupported,
"Server did not send the event name. The server is possibly too old. The event system is not initialized!",
"EventConsumer::initialize_received_from_admin()");

}

cout4 << "received_from_admin.event_name = " << received_from_admin.event_name << endl;
assert(!(received_from_admin.channel_name.empty()));
if (received_from_admin.channel_name.empty())
{
EventSystemExcept::throw_exception(API_NotSupported,
"Server did not send the channel name. The server is possibly too old. The event system is not initialized!",
"EventConsumer::initialize_received_from_admin()");
}
cout4 << "received_from_admin.channel_name = " << received_from_admin.channel_name << endl;
}

Expand Down

0 comments on commit 9535ad1

Please sign in to comment.