Java – put exceptions in your own sub package?
In the current package I'm working on for the project, I have about 13 different custom exceptions Is it a good idea to put these in a sub package under the package that contains all the classes that will use these exceptions?
For example:
Contains a bunch of classes that can throw some custom exceptions and put them in it
The only drawback I see now is that I use exceptions to import more classes
Solution
I don't think exceptions should go into another package because they connect to other classes in the project If a package is too crowded with many classes, you should split the package, but I prefer to split it according to functional standards
Anyway, with so many exception classes, I'll consider a base exception class that can be thrown instead of multiple special exceptions Things like myprojectexception