I would like to differentiate between exceptions coming from business logic like
- requested database record does not exist
- attempt to store invalid business data (validation failed)
- provided CSV file has wrong format
from standard system exceptions like
- database connection timeout
- file I/O error
- out of memory
I generate business logic exceptions in my code as a quick way to quit undergoing operation when something goes wrong (instead of returning
false and other techniques).
So I would implement different handling of these types of exceptions:
- my business logic exception: display as ordinary plain error message
- standard system exception: log exception to file, user is given options Abort / Ignore (/Retry) etc...
The best idea I could figure out was to create common ancestor for business exceptions and check it in the handler. I think this was original purpose of ApplicationException which is now deprecated. Do you think I can resurrect it for the purpose or is there some better approach?