diff --git a/src/ctbin/main.cpp b/src/ctbin/main.cpp index 3b0e8b4..d6e09ac 100644 --- a/src/ctbin/main.cpp +++ b/src/ctbin/main.cpp @@ -35,11 +35,33 @@ ***************************************************************************/ int main (int argc, char *argv[]) { + // Initialise return code + int rc = 1; + // Create instance of application ctbin application(argc, argv); - + // Run application - int rc = application.run(); + try { + application.run(); + rc = 0; + } + catch (std::exception &e) { + + // Extract error message + std::string message = e.what(); + std::string signal = "*** ERROR encounterted in the execution of" + " ctbin. Run aborted ..."; + + // Write error in logger + application.log << signal << std::endl; + application.log << message << std::endl; + + // Write error on standard output + std::cout << signal << std::endl; + std::cout << message << std::endl; + + } // endcatch: catched any application error // Return return rc; diff --git a/src/ctlike/main.cpp b/src/ctlike/main.cpp index 48282b4..73d3ac8 100644 --- a/src/ctlike/main.cpp +++ b/src/ctlike/main.cpp @@ -32,12 +32,34 @@ ***************************************************************************/ int main (int argc, char *argv[]) { + // Initialise return code + int rc = 1; + // Create instance of application ctlike application(argc, argv); - + // Run application - application.run(); + try { + application.run(); + rc = 0; + } + catch (std::exception &e) { + + // Extract error message + std::string message = e.what(); + std::string signal = "*** ERROR encounterted in the execution of" + " ctlike. Run aborted ..."; + + // Write error in logger + application.log << signal << std::endl; + application.log << message << std::endl; + + // Write error on standard output + std::cout << signal << std::endl; + std::cout << message << std::endl; + + } // endcatch: catched any application error // Return - return 0; + return rc; } diff --git a/src/ctselect/main.cpp b/src/ctselect/main.cpp index e2d2eb3..a18cf43 100644 --- a/src/ctselect/main.cpp +++ b/src/ctselect/main.cpp @@ -32,12 +32,34 @@ ***************************************************************************/ int main (int argc, char *argv[]) { + // Initialise return code + int rc = 1; + // Create instance of application ctselect application(argc, argv); - + // Run application - application.run(); + try { + application.run(); + rc = 0; + } + catch (std::exception &e) { + + // Extract error message + std::string message = e.what(); + std::string signal = "*** ERROR encounterted in the execution of" + " ctselect. Run aborted ..."; + + // Write error in logger + application.log << signal << std::endl; + application.log << message << std::endl; + + // Write error on standard output + std::cout << signal << std::endl; + std::cout << message << std::endl; + + } // endcatch: catched any application error // Return - return 0; + return rc; }