Catch all exception produced by a received message (irc or xmpp)
This commit is contained in:
@@ -93,7 +93,13 @@ void IrcClient::parse_in_buffer(const size_t)
|
|||||||
this->in_buf = this->in_buf.substr(pos + 2, std::string::npos);
|
this->in_buf = this->in_buf.substr(pos + 2, std::string::npos);
|
||||||
auto cb = irc_callbacks.find(message.command);
|
auto cb = irc_callbacks.find(message.command);
|
||||||
if (cb != irc_callbacks.end())
|
if (cb != irc_callbacks.end())
|
||||||
(this->*(cb->second))(message);
|
{
|
||||||
|
try {
|
||||||
|
(this->*(cb->second))(message);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
log_error("Unhandled exception: " << e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
log_info("No handler for command " << message.command);
|
log_info("No handler for command " << message.command);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,13 @@ void XmppParser::char_data(const XML_Char* data, int len)
|
|||||||
void XmppParser::stanza_event(const Stanza& stanza) const
|
void XmppParser::stanza_event(const Stanza& stanza) const
|
||||||
{
|
{
|
||||||
for (const auto& callback: this->stanza_callbacks)
|
for (const auto& callback: this->stanza_callbacks)
|
||||||
callback(stanza);
|
{
|
||||||
|
try {
|
||||||
|
callback(stanza);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
log_debug("Unhandled exception: " << e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmppParser::stream_open_event(const XmlNode& node) const
|
void XmppParser::stream_open_event(const XmlNode& node) const
|
||||||
|
|||||||
Reference in New Issue
Block a user