Most Powerful Open Source ERP

Guideline Never Hide Exceptions

It may lead to system corruption.
  • Last Update:2017-09-04
  • Version:001
  • Language:en

Never Hide Exceptions

Never hide exceptions to the user because exceptions may result in data inconsistency or system unstability and corruption. It is better to display an error to the user rather than finish a transaction and save corrupted data. At least, someone knows there is an error. Otherwise, errors happen, data is corrupted, and nobody knows. For example, make sure that SQLCatalog ZSQL methods generate exceptions and errors in the user interface in case of syntax error or database adapter connectivity problem.

Remember that hasattr hides all exceptions, including ZODB Conflict Errors, it's much safer to use getattr(obj, name, _marker)is not _marker in those situations.

As long as you re-raise the same exception, you can catch all types of exceptions.

Good Example:

try:
  ...
except:
  LOG(...)
  raise

Bad Example:

try:
  ...
except:
  pass