diff options
| author | 2014-04-16 13:08:44 +0200 | |
|---|---|---|
| committer | 2014-04-16 13:08:44 +0200 | |
| commit | 3eb205218a321e454d873ae14e2e717ce9d64142 (patch) | |
| tree | 4f0c4aabf7fe7c51b329e09b59984977869fd786 /src/modules/m_spanningtree/servercommand.h | |
| parent | Remove WALLCHOPS and WALLVOICES ISUPPORT tokens (diff) | |
m_spanningtree Throw an exception on protocol violations instead of returning CMD_INVALID
Catch CoreExceptions, log and close the link in OnDataReady()
Diffstat (limited to 'src/modules/m_spanningtree/servercommand.h')
| -rw-r--r-- | src/modules/m_spanningtree/servercommand.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/modules/m_spanningtree/servercommand.h b/src/modules/m_spanningtree/servercommand.h index 156b405e4..f99942079 100644 --- a/src/modules/m_spanningtree/servercommand.h +++ b/src/modules/m_spanningtree/servercommand.h @@ -22,6 +22,15 @@ #include "utils.h" #include "treeserver.h" +class ProtocolException : public ModuleException +{ + public: + ProtocolException(const std::string& msg) + : ModuleException("Protocol violation: " + msg) + { + } +}; + /** Base class for server-to-server commands that may have a (remote) user source or server source. */ class ServerCommand : public CommandBase @@ -47,7 +56,7 @@ class UserOnlyServerCommand : public ServerCommand { RemoteUser* remoteuser = IS_REMOTE(user); if (!remoteuser) - return CMD_INVALID; + throw ProtocolException("Invalid source"); return static_cast<T*>(this)->HandleRemote(remoteuser, parameters); } }; @@ -65,7 +74,7 @@ class ServerOnlyServerCommand : public ServerCommand CmdResult Handle(User* user, std::vector<std::string>& parameters) { if (!IS_SERVER(user)) - return CMD_INVALID; + throw ProtocolException("Invalid source"); TreeServer* server = TreeServer::Get(user); return static_cast<T*>(this)->HandleServer(server, parameters); } |
