@@ -17,18 +17,19 @@ See LICENSE for license details.
1717
1818#include " types.h"
1919
20- /*
21- * Note: the exceptions here are not exposed by the compiler, that means they won't travel over DSO (plugin) boundaries.
22- *
23- */
20+ #define API __attribute__ ((visibility(" default" )))
21+
22+ // Because exceptions are (potentially) visible to plugins, we want to make sure to avoid symbol collisions, so using their own namespace.
23+ namespace FlashMQ
24+ {
2425
2526/* *
2627 * @brief The ProtocolError class is handled by the error handler in the worker threads and is used to make decisions about if and how
2728 * to inform a client and log the message.
2829 *
2930 * It's mainly meant for errors that can be communicated with MQTT packets.
3031 */
31- class ProtocolError : public std ::runtime_error
32+ class API ProtocolError : public std::runtime_error
3233{
3334public:
3435 const ReasonCodes reasonCode;
@@ -40,7 +41,7 @@ class ProtocolError : public std::runtime_error
4041 }
4142};
4243
43- class BadClientException : public std ::runtime_error
44+ class API BadClientException : public std::runtime_error
4445{
4546 std::optional<int > mLogLevel ;
4647
@@ -55,41 +56,45 @@ class BadClientException : public std::runtime_error
5556
5657};
5758
58- class NotImplementedException : public std ::runtime_error
59+ class API NotImplementedException : public std::runtime_error
5960{
6061public:
6162 NotImplementedException (const std::string &msg) : std::runtime_error(msg) {}
6263};
6364
64- class FatalError : public std ::runtime_error
65+ class API FatalError : public std::runtime_error
6566{
6667public:
6768 FatalError (const std::string &msg) : std::runtime_error(msg) {}
6869};
6970
70- class ConfigFileException : public std ::runtime_error
71+ class API ConfigFileException : public std::runtime_error
7172{
7273public:
7374 ConfigFileException (const std::string &msg) : std::runtime_error(msg) {}
7475 ConfigFileException (std::ostringstream oss) : std::runtime_error(oss.str()) {}
7576};
7677
77- class pluginException : public std ::runtime_error
78+ class API pluginException : public std::runtime_error
7879{
7980public:
8081 pluginException (const std::string &msg) : std::runtime_error(msg) {}
8182};
8283
83- class BadWebsocketVersionException : public std ::runtime_error
84+ class API BadWebsocketVersionException : public std::runtime_error
8485{
8586public:
8687 BadWebsocketVersionException (const std::string &msg) : std::runtime_error(msg) {}
8788};
8889
89- class BadHttpRequest : public std ::runtime_error
90+ class API BadHttpRequest : public std::runtime_error
9091{
9192public:
9293 BadHttpRequest (const std::string &msg) : std::runtime_error(msg) {}
9394};
9495
96+ }
97+
98+ using namespace FlashMQ ;
99+
95100#endif // EXCEPTIONS_H
0 commit comments