-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
Add main function wrapper to catch exceptions and avoid annoying error popup on windows #768
Conversation
Thanks for the contribution. I fully agree with the need! Few remarks regarding the implementation: 2/ I would keep main.hpp as a header only file and I would also remove the intermediate aliceVision_main_wrapper, as we can just put the try/catch in the real main. What do think? |
Hi, |
src/aliceVision/system/main.hpp
Outdated
*/ | ||
int aliceVision_main(int argc, char* argv[]); | ||
|
||
// Inline to ensure the right main() is used (libf2c also has one...) |
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.
I would suggest a more explicit comment, like:
// Implementation of the unique main entry point.
// This method will call aliceVision_main and catch the exceptions to
// log the error message and avoid seg fault on exception on windows.
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.
Ok, I expanded the comment.
It would be good to apply it on all |
Yes. I would have done that as a follow-up PR, but I can add it to this one as well. |
Description
This adds a wrapper around
main()
functions to deal with unhandled exceptions by printing a "fatal" log message and exiting.The motivation is the behavior of unhandled exceptions on MSVC. There, such an exception simply terminates the program, but the exception message is not output anywhere! This can make troubleshooting very confusing, as the log of a tool gives no indication of a problem.
Features list
Not really a feature.
Implementation remarks
Wrapper is "opt-in" by including
system/main.hpp
.The header defines a macro
main
so themain()
function in the source appears like the real one even though it's wrapped. It's also convenient.