Commit 5999b560e70d0558bd23e2ee436f0905fa182e93

Authored by knodlseder
1 parent 402b67ad

add try-catch around application

src/ctselect/ctselect.cpp
... ... @@ -32,11 +32,23 @@
32 32 ***************************************************************************/
33 33 int main (int argc, char *argv[])
34 34 {
35   - // Create instance of application
36   - ctselect application(argc, argv);
  35 + // Initialise return code
  36 + int rc = 0;
37 37  
38   - // Run application
39   - int rc = application.run();
  38 + // Put all code in try-catch brackets to catch all errors
  39 + try {
  40 +
  41 + // Create instance of application
  42 + ctselect application(argc, argv);
  43 +
  44 + // Run application
  45 + rc = application.run();
  46 +
  47 + }
  48 + catch (std::exception &e) {
  49 + std::cout << e.what() << std::endl;
  50 + rc = -1;
  51 + }
40 52  
41 53 // Return
42 54 return rc;
... ... @@ -51,6 +63,15 @@ int ctselect::run(void)
51 63 // Test dump
52 64 std::cout << *this << std::endl;
53 65  
  66 + // DUMMY FOR TESTING
  67 + std::string value;
  68 + value = par("string")->value();
  69 + std::cout << value << std::endl;
  70 + value = par("chatter")->value();
  71 + std::cout << value << std::endl;
  72 + value = par("clobber")->value();
  73 + std::cout << value << std::endl;
  74 +
54 75 // Return
55 76 return 0;
56 77 }
... ...
src/ctselect/ctselect.hpp
... ... @@ -35,7 +35,7 @@
35 35 class ctselect : public GApplication {
36 36 public:
37 37 // Constructors and destructors
38   - ctselect(int argc, char *argv[]) :
  38 + ctselect(int argc, char *argv[]) :
39 39 GApplication(APP_NAME, APP_VERSION, argc, argv) { return; }
40 40  
41 41 // Methods
... ...