From 5999b560e70d0558bd23e2ee436f0905fa182e93 Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Tue, 18 May 2010 12:28:13 +0000 Subject: [PATCH] add try-catch around application --- src/ctselect/ctselect.cpp | 29 +++++++++++++++++++++++++---- src/ctselect/ctselect.hpp | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index a31f29d..5960fcb 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -32,11 +32,23 @@ ***************************************************************************/ int main (int argc, char *argv[]) { - // Create instance of application - ctselect application(argc, argv); + // Initialise return code + int rc = 0; - // Run application - int rc = application.run(); + // Put all code in try-catch brackets to catch all errors + try { + + // Create instance of application + ctselect application(argc, argv); + + // Run application + rc = application.run(); + + } + catch (std::exception &e) { + std::cout << e.what() << std::endl; + rc = -1; + } // Return return rc; @@ -51,6 +63,15 @@ int ctselect::run(void) // Test dump std::cout << *this << std::endl; + // DUMMY FOR TESTING + std::string value; + value = par("string")->value(); + std::cout << value << std::endl; + value = par("chatter")->value(); + std::cout << value << std::endl; + value = par("clobber")->value(); + std::cout << value << std::endl; + // Return return 0; } diff --git a/src/ctselect/ctselect.hpp b/src/ctselect/ctselect.hpp index 9cfe710..b22cea2 100644 --- a/src/ctselect/ctselect.hpp +++ b/src/ctselect/ctselect.hpp @@ -35,7 +35,7 @@ class ctselect : public GApplication { public: // Constructors and destructors - ctselect(int argc, char *argv[]) : + ctselect(int argc, char *argv[]) : GApplication(APP_NAME, APP_VERSION, argc, argv) { return; } // Methods -- libgit2 0.21.4