Transactions and error handling in a Web app
I have some head ache about some design decisions and would like to hear your opinion.
I have a web app with the following layers.
Presentation (Spring MVC controllers)
Facade (wrapping service calls into "use case" method calls. )
Service ("Global" try/catch(Throwable), translating any Exceptions into ResultObjects)
* Communitation between Service->Facade->Presentation are made via ResultObjects.
* Spring Declarative Transaction support are supposed to start in the Facade layer.
* The Presentation layer should not be aware of any Exceptions thrown in any layers under it, it should always recieve a ResultObject regardless if it contains an ok message, including the result, or only an error message
* If I catch all exceptions in the Service layer, what about our declarative transactions, don't they rely on an exception is thrown from the wrapped "transacted" method ?
* What about an CreateResultObjectFromExcaption Aspect (around or after throwing advice?) which triggers on an exception thrown from the Facade layer (rethrow the exception caught in Service rather than creating a ResultObject), creating a ResultObject based on the exception? Which aspect will trigger first, the Declarative Transaction aspect or the around/after throwing advice, i.e will the transaction do the rollback before my CreateResultObjectFromExcaption or after?
* Should I have the transactions around the service layer methods and create my ResultObject in the Facade (throw exception from the Service layer). What about rollback if service call A is fine but service call B fails?
* Do I have to let all exceptions propagate all the way to the Presentation layer which make this layer responsible for business issues like i18n, "exception translation" and such?
Need more info about my situation?