Skip to content

Commit

Permalink
Also catch exceptions not derived from std::exception
Browse files Browse the repository at this point in the history
  • Loading branch information
achim-k committed Apr 27, 2023
1 parent 1fc7ba0 commit 16d34c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class CallbackQueue {
const std::string msg =
std::string("Caught unhandled exception in calback_queue") + ex.what();
_logCallback(WebSocketLogLevel::Error, msg.c_str());
} catch (...) {
_logCallback(WebSocketLogLevel::Error, "Caught unhandled exception in calback_queue");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ inline void Server<ServerConfiguration>::handleMessage(ConnHandle hdl, MessagePt
handleTextMessage(hdl, msg);
} catch (const std::exception& e) {
sendStatusAndLogMsg(hdl, StatusLevel::Error, e.what());
} catch (...) {
sendStatusAndLogMsg(hdl, StatusLevel::Error,
"Exception occurred when executing text message handler");
}
});
} break;
Expand All @@ -570,6 +573,9 @@ inline void Server<ServerConfiguration>::handleMessage(ConnHandle hdl, MessagePt
handleBinaryMessage(hdl, msg);
} catch (const std::exception& e) {
sendStatusAndLogMsg(hdl, StatusLevel::Error, e.what());
} catch (...) {
sendStatusAndLogMsg(hdl, StatusLevel::Error,
"Exception occurred when executing binary message handler");
}
});
} break;
Expand Down

0 comments on commit 16d34c0

Please sign in to comment.