How can I change the error attributes that are exposed when throwing a ResponseStatusException
?
Especially I want to hide the exception
, error
and status
type in the json, but only during production.
@RestController
public class MyController {
@GetMapping("/test")
public Object get() {
throw new org.springframework.web.server.ResponseStatusException(
HttpStatus.Forbidden, "some message");
}
}
Result:
{
"timestamp": "2018-11-06T12:16:50.111+0000",
"status": 403,
"error": "Forbidden",
"exception": "org.springframework.web.server.ResponseStatusException",
"message": "some message",
"path": "/test"
}