
Mastering Apex Programming
By :

Broadly speaking, I like to divide exceptions into three types: expected exceptions, unexpected exceptions, and unknown exceptions. Let's look at what is meant by each of these types.
Expected exceptions are ones that we anticipate occurring and want to handle appropriately. An example would be some validation logic in code or a required field for a process to occur. When developing the code, you are aware of these items and the exceptions that they will throw and will want to inform the user appropriately. If they press the Send Invoice button and there is no email address, they should be informed.
Your code has been working for a period of time without any hiccups, then suddenly someone changes the system and does not verify the impacts of the change.
At the time of writing this, I have just been dealing with a bug in a system relating to a code-based process that was originally...