code: @Override
    public Response toResponse(WebApplicationException exception) {
  
      Response response = exception.getResponse();
      int code = response == null ? INTERNAL_SERVER_ERROR.getStatusCode() : response.getStatus();
  
      if (code >= 400 && code < 500) {
        logger.warn("An unhandled exception was thrown.", exception);
      } else if (code >= 500) {
        logger.error("An unhandled exception was thrown.", exception);
      }
  
      return Optional.ofNullable(exception.getResponse())
          .map(Response::fromResponse)
          .orElse(Response.status(code))
          .entity(
              JsonError.builder()
                  .code(code)
                  .message(getMessage(code))
                  .build())
          .type(MediaType.APPLICATION_JSON)
          .build();
    }
docs: Maps an unhandled {@link WebApplicationException} to a {@link Response}.
  
  @param exception the {@link WebApplicationException} that was not handled
  @return a {@link Response} object with a status of the {@link WebApplicationException} or 500
  if the exception's response is null, content-type of 'application/json', and a
  {@link JsonError} entity containing details about the unhandled exception in JSON format