I have written simple REST application in Spring Boot
(Spring
Framework).
It returns ResponseEntity<Success>
as Success response in the controller level. But I want to return a completely different Error response ResponseEntity<Error>
, if there is an error (validation error, logic error, runtime error) in the API.
Success& Error responses are completely different for the application.Success
& Error
are the 2 java classes which the application uses to represent Success& Error responses.
What is the best way to return different types of ResponseEntity
in Spring-Boot
(Best way to handle the errors for REST with Spring
)?