What is the common or best practice to structure the location of your exception classes?
Let's say you have the packages/namespaces myproject.person
(models and DAOs for persons) and myproject.order
(models and DAOs for orders) and the exceptions PersonException
and OrderException
. Should I put the exceptions in their corresponding packages or in a separate package for exceptions (e.g. myproject.exceptions
)?
The first approach seems more reasonable (because it's sorted by functionality). But there the question arises where you should put exceptions that are related to both? e.g. a ConstraintViolationException