Most Powerful Open Source ERP

Guideline Code Should Work If All Else Fails

Always assume a part your code is depending on may not work.
  • Last Update:2019-07-15
  • Version:001
  • Language:en

Code Should Work If All Else Fails

It is a good idea to write code in such way that it has a consistent failover behaviour in case some assumptions are not met. For example, if a piece of code requires a regular expression which is obtained as a user preference, it is better to consider the case where the user forgot to enter the regular expression and provide a failover behaviour. If no consistent failover behaviour can be defined, then raising exceptions with clear message is the best thing to do.

A good practice is to raise an exception with a message stating "No regular expression was defined. The wrong way would be to throw an error.