@Override
    public Response toResponse(final IllegalStateException exception) {
        final String message = exception.getMessage();

        if (LocalizationMessages.FORM_PARAM_CONTENT_TYPE_ERROR().equals(message)) {
            /*
             * If a POST request contains a Content-Type that is not application/x-www-form-urlencoded, Jersey throws
             * IllegalStateException with or without @Consumes. See: https://java.net/jira/browse/JERSEY-2636
             */
            // Logs exception with additional information for developers.
            logger.debug("If the HTTP method is POST and using @FormParam in a resource method"
                + ", Content-Type should be application/x-www-form-urlencoded.", exception);
            // Returns the same response as if NotSupportedException was thrown.
            return createResponse(new NotSupportedException());
        }

        // LoggingExceptionMapper will log exception
        return super.toResponse(exception);
    }
@Test
    void handlesFormParamContentTypeError() {
        final Response reponse = mapper
            .toResponse(new IllegalStateException(LocalizationMessages.FORM_PARAM_CONTENT_TYPE_ERROR()));
        assertThat(reponse.getStatusInfo()).isEqualTo(UNSUPPORTED_MEDIA_TYPE);
        assertThat(reponse.getEntity()).isInstanceOf(ErrorMessage.class);
        assertThat(((ErrorMessage) reponse.getEntity()).getMessage())
            .isEqualTo(new NotSupportedException().getLocalizedMessage());
    }