I have this endpoint:
@GET
@Path("{id}")
public Response getActiveById(
@PathParam("id") @NotNull(message = "id may not be null") Long id) {
try {
AccountDTO accountDTO = accountService
.getActiveById(id);
GenericEntity<AccountDTO> accountDTOGenericEntity = new GenericEntity<AccountDTO>(
accountDTO) {
};
return Response.status(Response.Status.OK).entity(accountDTOGenericEntity).build();
} catch (Exception e) {
logger.error(e.getMessage());
return Response.status(Status.NOT_FOUND)
.entity(new ErrorInfo("ACCOUNT_SERVICE", "ACCOUNT ID NOT FOUND") {
}).build();
}
}
And when someone passes a string it returns 500 internal server error but I wanted to return 400 bad request. I would not like to change the type of the parameter because the right type is long. Do you have any ideas?