Skip to content

Commit ac8a9a5

Browse files
author
jarulraj
committed
Catch exceptions in main
1 parent 0bf8916 commit ac8a9a5

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/main.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ Configuration state;
1414

1515
int main(int argc, char **argv) {
1616

17-
sqlcheck::ParseArguments(
18-
argc, argv, sqlcheck::state);
17+
try {
1918

20-
sqlcheck::Check(sqlcheck::state);
19+
// Parse the input arguments from the user
20+
// This customizes the checker configuration
21+
sqlcheck::ParseArguments(
22+
argc, argv, sqlcheck::state);
2123

22-
return 0;
24+
// Invoke the checker
25+
sqlcheck::Check(sqlcheck::state);
26+
27+
}
28+
// Catching at the top level ensures that
29+
// destructors are always called
30+
catch (std::exception& exc) {
31+
std::cerr << exc.what() << std::endl;
32+
exit(EXIT_FAILURE);
33+
}
34+
35+
return (EXIT_SUCCESS);
2336
}

0 commit comments

Comments
 (0)