mainly for testing and debugging
     IoServiceItem io_service;
     int ret_code = 0;
     unsigned n_exceptions = 0;
+    unsigned max_exceptions = 1;
     try
     {
         ConfigurationItem configuration = get_configuration( argc, argv );
                 ++n_exceptions;
                 GlobalLogger.error() << "Caught unknown exception, will continue!" << endl;
             }
+
+            if (max_exceptions > 0 && n_exceptions >= max_exceptions)
+            {
+                GlobalLogger.info() << "reached max number of exceptions allowed in main loop" << endl;
+                io_service->stop();
+                signal_data.stopped = true;
+                break;
+            }
         }
     }