Skip to content

Commit

Permalink
Catch main() exceptions in Debug mode as well
Browse files Browse the repository at this point in the history
The reason for catching only on Release mode
was the loss of exception type information.
Now with Boost exception and RTTI,
this information can be retrieved without loss,
so the Debug mode does not need to crash.

Issue #219
  • Loading branch information
rakhimov committed Oct 15, 2017
1 parent 86632fa commit 7f1755c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/scram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ void RunScram(const po::variables_map& vm) {
/// @returns 0 for success.
/// @returns 1 for errored state.
int main(int argc, char* argv[]) {
#ifdef NDEBUG
try { // Catch exceptions only for non-debug builds.
#endif

try {
// Parse command-line options.
po::variables_map vm;
int ret = ParseArguments(argc, argv, &vm);
Expand All @@ -307,8 +304,6 @@ int main(int argc, char* argv[]) {

if (ret == 0)
RunScram(vm);

#ifdef NDEBUG
} catch (const scram::LogicError& err) {
LOG(scram::ERROR) << "Logic Error:\n" << boost::diagnostic_information(err);
return 1;
Expand Down Expand Up @@ -363,5 +358,4 @@ int main(int argc, char* argv[]) {
<< err.what();
return 1;
}
#endif
} // End of main.

0 comments on commit 7f1755c

Please sign in to comment.