-
Notifications
You must be signed in to change notification settings - Fork 7.9k
remove try/catch from ~PooledConnection
#89090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the try-catch block from the ~PooledConnection() destructor, eliminating the exception handling that was previously suppressing and logging any exceptions thrown during connection cleanup.
Key Changes:
- Removed try-catch wrapper from the destructor body
- Eliminated the
tryLogCurrentExceptioncall that was logging caught exceptions
| ~PooledConnection() override | ||
| { | ||
| try | ||
| if (bool(response_stream)) | ||
| { |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the try-catch block from a destructor is risky because destructors are implicitly noexcept in C++11 and later. If any exception is thrown during the cleanup operations (e.g., from response_stream operations or metrics updates), the program will call std::terminate() and crash. Consider either keeping the try-catch to handle exceptions gracefully, or ensure all operations within the destructor are guaranteed not to throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding try catch in every d-tors makes a noise.
You mute exception in d-tor not by choice but out of necessity, as a result you mute an undefined wide set of exceptions. Much better approach is to guarantee that all actions in d-tor are not able to throw.
remove try/catch from `~PooledConnection`
remove try/catch from `~PooledConnection`
Changelog category (leave one):