Quote Originally Posted by axxa View Post
The thought has crossed my mind, but I'm not too sure it will be the easiest way since each (most) call from a service to integration, throwing an exception, will need their own messageCode, e.g findUserById() -> "error.user.not.existing", findOrderById() -> "error.order.not.existing" etc.
Or do you have an idea how to solve this, without having to create an aspect for each service call? ...Just about learning to use AOP so every new "aspect" on the matter is welcome!
OK, see what your saying. One way of doing it would be to decide on a general set of exceptions and the related messages. You could then create an abstract bean and a bean that uses this as the parent for each service. You then inject in the messages for each type of exception. So in the user service aspect objectNotFound=error.user.not.existing, in role service aspect objectNotFound=error.role.not.existing. If there are exceptions specific to the service you can then subclass the base aspect.

It just means that for the services that throw general exceptions theres not much to do. For the ones that do something specific theres a lot less to do.

One thing you might have to think about is transactions. If your exceptions aren't runtime your going to have to configure what triggers a rollback etc....