I have a custom exception class annotated to return a given HttpStatus
:
@ResponseStatus(value=HttpStatus.BAD_REQUEST, reason=\"Invalid parameter\")
If you omit the 'reason' attribute in the @ResponseStatus annotation on a custom exception,
@ResponseStatus(value = HttpStatus.CONFLICT) // 409
public class ChildDataExists extends RuntimeException {
...
then throw the exception
throw new ChildDataExists("Can't delete parent if child row exists.");
The exception's message comes through as the 'message' of the 'data' in the JSON output. It seems the 'reason' in the annotation overrides the custom behavior.