From 0a9df94fffffb2182836e69b7a33d4d455a34fc7 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Tue, 3 Dec 2024 01:43:39 +0300 Subject: [PATCH] Wrap main() into try catch. --- src/tesseract.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tesseract.cpp b/src/tesseract.cpp index 08a65e147e..57c7861057 100644 --- a/src/tesseract.cpp +++ b/src/tesseract.cpp @@ -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__) @@ -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; +}