Skip to content
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

Exception handling for DB failure #20457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AaronGulman
Copy link

Hi,
This PR is aimed at exception handling for the DB initialization process within the server's authentication module. By wrapping the StartDB() function in a try-catch block, this change ensures that any exceptions thrown during DB startup are properly caught and logged, preventing the server from failing silently if the database connection cannot be established. Specifically, it logs an error message and exits with code 1 if the initialization fails.

The change has been tested by me in a controlled dev env to ensure the exception handling works as expected.

I hope you find this tiny change useful ! I apologize if it is not (I am mostly a full stack web dev!)

Good luck !

@github-actions github-actions bot added CORE Related to the core file-cpp Used to trigger the matrix build labels Nov 6, 2024
} catch (const std::exception& ex) {
LOG_ERROR("server.authserver", "Database initialization failed: {}", ex.what());
return 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello and thanks for your contribution! can you please fix the code indentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CORE Related to the core file-cpp Used to trigger the matrix build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants