-1
Everybody, good afternoon, everybody!
I need a help, I am creating some java Apis and I created some custom exceptions, when I invoke the type exection I created: throw new Recursonancontradoexception("Resource not found"); , I get return in Json, without the message field filled : { "timestamp": "2020-12-10T17:04:44.123+00:00", "status": 404, "error": "Not Found", "message": ", "path": "/mkpnumapi/v1/if/1111" }
someone knows how to say why is not capturing the message I send ?
My Class that created the Exception Runtimeexception Exclusion
@ResponseStatus(HttpStatus.NOT_FOUND)
public class RecursoNaoEncontradoException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
public RecursoNaoEncontradoException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
}
Chamadando a Exception na minha controller
@ApiOperation(value = "Metodo - deletarOfertante", nickname = "deletarOfertante")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK - Request Aceito"),
@ApiResponse(code = 400, message = "Bad Request - Request ou Parametros Incorretos") })
@DeleteMapping(value = "/ofertante/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deletarOfertante(@PathVariable(value = "id") String id) {
Integer result = service.buscarOfertantePorId(id);
if (result == 0) {
throw new RecursoNaoEncontradoException("Recurso inexistente");
}
return new ResponseEntity<>(service.excluirOfertante(id), HttpStatus.OK);
}
Retorno Response:
{ "timestamp": "2020-12-10T17:04:44.123+00:00", "status": 404, "error": "Not Found", "message": ", "path": "/mkpnumapi/v1/if/1111" }
Without the code you can’t guess.
– user201641
Opa Adriano, I added the code.
– Joo Pereira de albuquer Junior
@Adrianosiqueira added the code.
– Joo Pereira de albuquer Junior