Exception handling in intialization routine

Discussion of ideas for features and new projects based on POCO.
Paranaix
Posts: 4
Joined: 08 Jan 2012, 21:52

Exception handling in intialization routine

Postby Paranaix » 08 Jan 2012, 22:02

Hey,
I found a little design flaw in the Poco::Util::Application class.
Poco::Util::Application::run():

Code: Select all

int Application::run()
{
   int rc = EXIT_SOFTWARE;
   initialize(*this);
   try
   {
      rc = main(_args);
   }
   catch (Poco::Exception& exc)
   {
      logger().log(exc);
   }
   catch (std::exception& exc)
   {
      logger().error(exc.what());
   }
   catch (...)
   {
      logger().fatal("system exception");
   }
   uninitialize();
   return rc;
}


Although exceptions thrown in main() are logged, those in initialize() are not. This is important to me since i need to verify some configuration values which are required for the initialization.
Throwing a exception, if values are not correct, will cause termination of the programm but no logging.
Its easy to change that in the next version by putting initialize() in the try block.

guenter
Posts: 1194
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Exception handling in intialization routine

Postby guenter » 10 Jan 2012, 14:46

I've fixed that in 1.4.3.


Return to “Wishlist”

Who is online

Users browsing this forum: No registered users and 1 guest

cron