My spring boot @RestControllerAdvice is overriding the @ResponseStatus of my Exception class (that extends RuntimeException). It is defaulting to 200. But it works when it put the @ResponseStatus over the handler method.
@ExceptionalHandler(MyCustomException.class)
@ResponseStatus(value = Http.BAD_REQUEST)
public MyCustomErrorClass handleMyCustomException( MyCustomException e) {
return buildMyCustomErrorClass(e);
}
Can I please know what's the correct usage? Where Should I place the @ResponseStatus? On the exception, on the controller or both? I thought the annotation over exception is a clean way.