My application architecture can roughly be represented like this:
UI --> Domain Model --> PersistenceService (Caching etc.) --> Mapping Layer
The Mapping Layer consists of interfaces that are like DAOs (just get, insert, update and delete), The Persistence Layer uses these interfaces and adds caches and checks to avoid unneccessary updates.
In theory, there are various implementations for the Mapping Layer, for example, one could map to xml files or to an SQL database; but because the mappers interact with the "outside world", they usually throw checked exceptions (IOException, SomeSQLException ...).
First problem is, how can I unify my Mapper interfaces, if the Exceptions are different for each implementation? I could create a new exception (MapperException) that can be thrown, and then I would "bubble up" the exception, through my persistence layer, through the domain layer, until the UI catches it and displays a (generic) error message.
And here is the thing I don't like; the exceptions are checked exceptions, however there is no class or layer that can actually handle them, they are just passed up until they are displayed and thats it. It seems weird to have a throws-clause on nearly every method, just because some of the low level classes throw checked exceptions that should be handled.
Can I just convert the checked exceptions to unchecked exceptions? How would I make sure that they are still catched in the UI?
Or can I somehow inject an exception handler into the lower layers that is provided by the UI layer?
Is there some kind of best practice to this? So far I have rarely dealt with exceptions because the usually do not occur and I didn't care about proper exception handling in my earlier private projects.