Ticket #118 (closed enhancement: wontimplement)

Opened 3 years ago

Last modified 2 years ago

Default catch to avoid exiting fawkes

Reported by: crath Owned by: tim
Priority: minor Milestone: 0.4
Component: Fawkes Version:
Keywords: Cc:
Git Branch:

Description

I suggest to add a default catch when executing plugin loops. If an exception is thrown, that isn't catched within the plugin, the executed plugin should be removed but fawkes should still keep running.

Change History

Changed 2 years ago by tim

  • status changed from new to accepted

The infrastructure to provide this is actually not easy to implement. The plugin threads are executed in their own context, thus there is no "enclosing" instance of the main app to catch exceptions. A generic try/catch block in the Thread implementation would have bad side effects. There is nothing sensible the thread can do with the error, it does not have access to the logger, the availability of stdout/stderr cannot be assumed (may run as daemon), and without more information of the kind of error it cannot decide whether the error is critical and permanent or just transient. So the user won't even see a warning/error that something happened, although this might indicate a permanent failure like hardware that went missing.

So adding this kind of functionality would most likely just hide software bugs and make it harder to find them. Additionally, it can only reliably catch exceptions of a common base class (like fawkes::Exception), when integrating 3rd-party software this doesn't help (and we ran into this very problem at RC2009 with the KNI/Katana library). We cannot use the variadic catch all (...) because this also hides critical exceptions that must be rethrown for proper program operation (but which we cannot easily decide).

What could be an option is implement an optional "ignore exceptions" mode. We could add a pre-compiler flag like THREAD_LOOP_IGNORE_EXCEPTIONS that adds the appropriate code to run() to catch any exceptions and ignore them. However, this can only properly handle Fawkes exceptions for the reasons outlined above. And they should be pretty predictable. You can always add a generic try/catch and at least log the error in your plugin loop. Having the generic ignore construct would to some degree support sloppy programming, so I'm not keen to add it.

Can you give some examples where this has been a problem? In AtHome? we only encountered problems with exceptions from external applications.

Changed 2 years ago by tim

  • milestone changed from 0.3 to 0.4

Changed 2 years ago by tim

  • status changed from accepted to closed
  • resolution set to wontimplement

As discussed and explained  on the mailing list (also read reply) there is no proper way to implement this. The plugins know best and they should handle all exceptions, it's considered a bug otherwise. Therefore closing.

Note: See TracTickets for help on using tickets.

This list contains all users that will be notified about changes made to this ticket.

These roles will be notified: Reporter, Subscriber, Participant

  • Christof Rath(Reporter)
  • Fawkes Trac List(Always)
  • Tim Niemueller(Owner, Participant)