Throw from readDeck() instead of std::exit()#6935
Open
hakonhagland wants to merge 1 commit intoOPM:masterfrom
Open
Throw from readDeck() instead of std::exit()#6935hakonhagland wants to merge 1 commit intoOPM:masterfrom
hakonhagland wants to merge 1 commit intoOPM:masterfrom
Conversation
Replace MPI_Finalize + std::exit(EXIT_FAILURE) with throw std::runtime_error in readDeck() on parse failure. This lets callers handle the error: Main::initialize_() catches it and calls MPI_Abort(), while Boost.Test catches it and reports a proper test failure instead of a silent exit. Widen the catch clause in Main::initialize_() from std::invalid_argument to std::exception to cover both existing and new exception types.
Contributor
Author
|
jenkins build this please |
Member
|
I still maintain that the unit test justification is just wrong. You should never add a unit test that has parse errors. |
Contributor
Author
Yes, but in my opinion during development it will be helpful to have this to catch deck errors quickly. |
Member
And you're making everything more difficult for the slight convenience of something that happens very infrequently. You should use other tools when developing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #6933.
Problem
When
readDeck()encounters unrecoverable parse errors, it callsMPI_Finalize()+std::exit(EXIT_FAILURE). This is problematic because:std::exit()bypasses Boost.Test, producing exit code 1 with no test failure reportMPI_Finalize()requires cooperative shutdown from all ranks; on an error pathMPI_Abort()is more appropriateSolution
readDeck.cpp: ReplaceMPI_Finalize()+std::exit(EXIT_FAILURE)withthrow std::runtime_error(failureMessage)Main.hpp: Widen catch inMain::initialize_()fromstd::invalid_argumenttostd::exceptionso it catches both existing and new exception types. The existingMPI_Abort()call in the catch block handles MPI cleanup correctly.Impact
MPI_Finalize+std::exit(1)Main::initialize_(),MPI_Abort, return falsestd::runtime_error, reports failure with message