It is very nice to have lots of different exceptions. Your code is declarative and robust. Or not?
Problems
Over Design
Namespace Pollution
Solutions
Avoid creating anemic exceptions as globals.
Create exceptions only if they behave differently.
Model exceptions with objects. Classes are handy for lazy programmers.
Sample Code
Wrong
Right
Detection
New exceptions should override behavior methods.
No. code, description, resumable, etc are not behavioral.
Tags
Abuser
Naming
Conclusion
You would not create different classes for every Person instance, so they return different names. Why would you do it with exceptions.
How often do you catch a specific exception?
Go out and check your code.
Is it necessary to be a class?
You are already coupled to the class. Couple to the description instead.
Exception instances should NOT be Singletons.

Singleton: The Root of all Evil
Maxi Contieri ・ Nov 17 '20 ・ 9 min read
Relations

Code Smell 01 - Anemic Models
Maxi Contieri ・ Oct 20 '20 ・ 1 min read
Credits
Photo by Nick van den Berg on Unsplash
You will fall to ruin because you believe that exceptions to the rule make new rules.
Pierce Brown
Discussion (0)