1

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?

PavlMits
  • 523
  • 2
  • 14
  • That's odd that you are getting a 500. The specification states that any error in parsing a `@PathParam` should lead to a 404. – Paul Samsotha Feb 08 '20 at 13:33

0 Answers0