pcah/python-clean-architecture

Error classes

jakos opened this issue · 1 comments

jakos commented

Create error classes that will be used in project. Change already used builtin error classes.

lhaze commented

I have a concept how to work with business process errors in a more convenient way than usual:

  • Have core of the application totally language independent; use error codes and translate them to literals in some language as late as possible: in the Presenter component of the server side or in the client side application.
  • Gather business logic errors in catalogs: an Enum-like class that gathers instances of errors concerning business validations & process interrupts of some specific domain. Look at the LogicErrors class in Valian/python-business-logic for an example how it could be done.
  • Libraries shouldn't use builtin error classes for two reasons:
    1. Depending application might want to catch all exceptions specific to the pca only.
    2. Raising eg. KeyError or TypeError may unexpectedly interact with some Key/TypeError naturally raised by syntax or runtime.