It is common practice to add the word “Exception” to the end of the class name of an exception to clearly differentiate it from other classes. For example, the class for exception concept of “file not found” is called FileNotFoundException. Likewise for Error types, they should be suffixed with “Error”.
However, classes that are RuntimeExceptions need only be suffixed with “Exception”.
Some real Exception names that never caught on.
Exception name |
Why |
---|---|
SomethingBadHappenedException |
Too general. When a developer catches this exception they do not know what to do with it. |
AssetFindNotFoundException |
Use of Find and Found in the same expression is unnecessary. |
ProcessingErrorException |
Is it an Error or an Exception? |
DatamismatchException |
M is not capitalized. Use DataMismatchException. |
PhoneNumberAuthenticationException |
Having an exception just for phone numbers implies a different exception for each kind of object. This is overkill unless the application is only about managing phone numbers. It becomes silly when you write a PostcodeAuthenticationException and SurnameAuthenticationException. |
ObjStoreFatalInternalException |
This should be an error, since the developer will not know what to do with it. |
VOException |
Makes it look like something to do with “VOE”. VirtualObjectException would have been much nicer. |
ProblemManagerException |
Isn't an Exception already a Problem? |
IChainableException |
Exceptions already have getCause() so why would you invent a new interface for it? |
NotAHandledAccountException |
Normally 'A' is implied, so this should read “NotHandledAccountException”. |
PhotoServiceAlreadyEnabled |
It is normal to end exceptions with the word “Exception”. |
GameNotOverException |
Exceptions are for exceptional circumstances. Normally the game would not be over so you would expect to see GameOverException. |
ELException |
Confusing. In Spanish this translates to “The Exception”. Probably should have been named ExpressionLanguageException. |
SSStopProcessingException |
Unwillingness to use camel case for acronyms gives this Exception a stutter. |
AmandaException |
I know she was horrible to you, but using your girlfriend's name in the code is unprofessional. |
Some Exception names that everybody loved.
NullPointerException
ImageScalingException
PhotoServiceAlreadyEnabledException
ConcurrentModificationException