Spring Data Rest exception handling - Return generic error response -


i want know how can handle internal server error type exceptions in spring data rest such jpa exceptions etc. due malformed request or database crash. did research found better way using @controlleradvice couldn't find working example of it. looked @ both these questions still unanswered.

how can handle exceptions spring data rest , pagingandsortingrepository?

global exception handling rest exposed spring-data

can me working example of how use @controlleradvice , write custom error response client whenever there exception.

you can this:

@controlleradvice(basepackageclasses = repositoryrestexceptionhandler.class) public class genericexceptionhandler {      @exceptionhandler     responseentity handle(exception e) {         return new responseentity("some message", new httpheaders(), httpstatus.bad_request);     } } 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -