diff options
Diffstat (limited to 'src/Core/ConnectionManager.cpp')
-rw-r--r-- | src/Core/ConnectionManager.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index 60f3ac4..2926fbf 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -162,32 +162,30 @@ void ConnectionManager::run() { refreshPollfds(); } -Net::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const { +Net::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const throw (Common::Exception&) { std::map<std::string,Net::ServerConnection*>::const_iterator daemon = identifiedDaemonConnections.find(name); if(daemon == identifiedDaemonConnections.end()) - return 0; + throw Common::Exception(Common::Exception::UNKNOWN_DAEMON); + + if(!daemon->second) + throw Common::Exception(Common::Exception::DAEMON_INACTIVE); return daemon->second; } -void ConnectionManager::identifyDaemonConnection(Net::Connection *connection, const std::string &name) { - // TODO Error handling +void ConnectionManager::identifyDaemonConnection(Net::Connection *connection, const std::string &name) throw (Common::Exception&) { + // TODO Logging - if(connection->isIdentified()) { - std::cerr << "Already identified." << std::endl; - return; - } + if(connection->isIdentified()) + throw Common::Exception(Common::Exception::ALREADY_IDENTIFIED); std::list<Net::ServerConnection*>::iterator con = std::find(daemonConnections.begin(), daemonConnections.end(), connection); - if(con == daemonConnections.end()) { - std::cerr << "Connection not found." << std::endl; - return; - } + if(con == daemonConnections.end()) + throw Common::Exception(Common::Exception::INVALID_ACTION); std::map<std::string,Net::ServerConnection*>::iterator idCon = identifiedDaemonConnections.find(name); if(idCon == identifiedDaemonConnections.end()) { - std::cerr << "Name not found." << std::endl; - return; + throw Common::Exception(Common::Exception::UNKNOWN_DAEMON); } if(idCon->second) { |