vendredi 17 juillet 2015

Python error handling in class hierarchy

I am currently working on a subsystem in Python, which has a following structure:

  1. Facade, which provides interface for communication with other subsystems (name it MyFacade)
  2. Engine (singleton) - receives requests from facade and dispathes them to "working" classes (MyEngine)
  3. Working modules - such as MyFileSystem, MyNetwork, MyDB and so on.

Thus there are three general levels: Facade - Engine - Worker.

If an error occurs somewhere - Facade must get it and show it to client, and application must not crash.

The question is: what is the best-practice Python way to organize error handling errors on all three levels of abstraction?

If an error occurs on the lowest level (Worker) - should I catch it, or return None/False?

What should be done on upper levels to provide necessary functionality and avoid violating DRY, SRP and so on?

Thx in advance!

Aucun commentaire:

Enregistrer un commentaire