@ExceptionHandler(IllegalArgumentException.
class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<?>
handleIllegalArgumentException(IllegalArgumentException exception,
WebRequest request) {
ProblemDetail pd = ProblemDetail
.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, "Ocorreu
um erro: '"
+ [Link]());
[Link]([Link]("[Link]
server-error"));
[Link]("Erro Interno");
[Link]("hostname", "localhost");
return [Link](500).body(pd);
}
[Link]-message=always
[Link]-binding-errors=always
[Link]-stacktrace=on-param
[Link]-exception=false
PerfilResumidoDto perfilDto = null;
try {
perfilDto = [Link](id);
}catch(IllegalArgumentException e) {
throw new IllegalArgumentException("Ocorreu uma exceção: " + e);
}
try {
perfilDto = [Link](perfil, [Link]);
}catch(IllegalArgumentException e) {
throw new IllegalArgumentException("Ocorreu uma exceção: ", e);
}
@ExceptionHandler([Link])
ProblemDetail handleNoSuchElementException(NoSuchElementException e) {
ProblemDetail problemDetail =
[Link](HttpStatus.NOT_FOUND, [Link]());
[Link]("Recurso Não Encontrado");
[Link]([Link]("[Link]
found"));
return problemDetail;
}