Capture exceptions in spring

Asked

Viewed 34 times

2

I’m using Spring and wanted to know how I can return the errors (Exception) from @Repository and/or @Service to my webservice?

I have the following structure:

[ Webservice ] ------ [ @service/@Transactional ] ------- [ @Repository ]

When launching some Exception on my DAO which elegant way to treat and return to my webservice?

1 answer

0

It depends on the webservice, if it is SOAP you will generate a FAULT as a response... In general this is already mapped automatically when you generate the stubs... If you are using pure http, Rest, just return a status consistent with the error. For example: 500 to say that an unexpected error occurred, 400 to indicate bad parameters...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.