summaryrefslogtreecommitdiff
path: root/src/bridge/bridge.hpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-05-11 04:47:31 +0200
committerFlorent Le Coz <louiz@louiz.org>2015-05-11 04:47:31 +0200
commit5475d16b574e1daf9c1e5f94b5b821bfb1b9c8f8 (patch)
treeed9cd935d27fa28963f9ea79f57fc18c6ae29a42 /src/bridge/bridge.hpp
parent71fec776c4d7b99b76a44deae6f333d9cffa1496 (diff)
downloadbiboumi-5475d16b574e1daf9c1e5f94b5b821bfb1b9c8f8.tar.gz
biboumi-5475d16b574e1daf9c1e5f94b5b821bfb1b9c8f8.tar.bz2
biboumi-5475d16b574e1daf9c1e5f94b5b821bfb1b9c8f8.tar.xz
biboumi-5475d16b574e1daf9c1e5f94b5b821bfb1b9c8f8.zip
Return a stanza error whenever the IRCClient for a given server does not exist
Instead of ignoring the stanza, we send back an error of type remote-server-not-found each time it's possible. Also avoid having to do if (!irc) return; everytime. fix #3045
Diffstat (limited to 'src/bridge/bridge.hpp')
-rw-r--r--src/bridge/bridge.hpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index cc9d042..72a8e90 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -9,6 +9,7 @@
#include <unordered_map>
#include <functional>
+#include <exception>
#include <string>
#include <memory>
@@ -193,11 +194,15 @@ private:
*/
IrcClient* get_irc_client(const std::string& hostname, const std::string& username);
/**
- * This version does not create the IrcClient if it does not exist, and
- * returns nullptr in that case
+ * This version does not create the IrcClient if it does not exist, throws
+ * a IRCServerNotConnected error in that case.
*/
IrcClient* get_irc_client(const std::string& hostname);
/**
+ * Idem, but returns nullptr if the server does not exist.
+ */
+ IrcClient* find_irc_client(const std::string& hostname);
+ /**
* The JID of the user associated with this bridge. Messages from/to this
* JID are only managed by this bridge.
*/
@@ -240,4 +245,11 @@ private:
Bridge& operator=(Bridge&&) = delete;
};
+struct IRCNotConnected: public std::exception
+{
+ IRCNotConnected(const std::string& hostname):
+ hostname(hostname) {}
+ const std::string hostname;
+};
+
#endif // BRIDGE_INCLUDED