Skip to content

Commit

Permalink
Wrap main() into try catch.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Dec 2, 2024
1 parent 2e5a114 commit 0a9df94
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/tesseract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ static void PreloadRenderers(tesseract::TessBaseAPI &api,
*
**********************************************************************/

int main(int argc, char **argv) {
int main1(int argc, char **argv) {
#if defined(__USE_GNU) && defined(HAVE_FEENABLEEXCEPT)
// Raise SIGFPE.
# if defined(__clang__)
Expand Down Expand Up @@ -852,3 +852,14 @@ int main(int argc, char **argv) {

return ret_val;
}

int main(int argc, char **argv) {
try {
return main1(argc, argv);
} catch (std::exception &e) {
std::cerr << "exception: " << e.what() << "\n";
} catch (...) {
std::cerr << "unknown exception\n";
}
return 1;
}

0 comments on commit 0a9df94

Please sign in to comment.