@Override
    public final void filter(DiscFilterRequest request, ResponseHandler handler) {
        filter(request)
                .ifPresent(errorResponse -> writeResponse(request, errorResponse, handler));
    }
@Test
    void filter_renders_errors_as_json() throws IOException {
        int statusCode = 403;
        String message = "Forbidden";
        DiscFilterRequest request = FilterTestUtils.newRequestBuilder().build();
        SimpleSecurityRequestFilter filter =
                new SimpleSecurityRequestFilter(new JsonSecurityRequestFilterBase.ErrorResponse(statusCode, message));
        RequestHandlerTestDriver.MockResponseHandler responseHandler = new RequestHandlerTestDriver.MockResponseHandler();
        filter.filter(request, responseHandler);

        Response response = responseHandler.getResponse();
        assertNotNull(response);
        assertEquals(statusCode, response.getStatus());

        JsonNode jsonNode = Jackson.mapper().readTree(responseHandler.readAll());
        assertEquals(message, jsonNode.get("message").asText());
        assertEquals(statusCode, jsonNode.get("code").asInt());
    }