When to use Exceptions

Date: 2020-10-28

Source: http://www.codinghell.ch/blog/2013/03/31/how-and-when-not-to-use-exceptions/

Exception as in exceptional

Exceptions should be used for situation where a certain method or function could not execute normally. For example, when it encounters broken input or when a resource (e.g. a file) is unavailable. Use exceptions to signal the caller that you faced an error which you are unwilling or unable to handle. The exception is then passed to the caller who has the chance to either handle the exception or pass it on (chain-of-responsibility).

41840cookie-checkWhen to use Exceptions