private void checkErrorResponse(AbstractRequest req, Throwable e) {
        AbstractResponse response = req.getErrorResponse(e);
        checkResponse(response, req.version());
        Errors error = Errors.forException(e);
        Map<Errors, Integer> errorCounts = response.errorCounts();
        assertEquals(Collections.singleton(error), errorCounts.keySet(),
                "API Key " + req.apiKey().name + " v" + req.version() + " failed errorCounts test");
        assertTrue(errorCounts.get(error) > 0);
        if (e instanceof UnknownServerException) {
            String responseStr = response.toString();
            assertFalse(responseStr.contains(e.getMessage()),
                    String.format("Unknown message included in response for %s: %s ", req.apiKey(), responseStr));
        }
    }
Check that all error codes in the response get included in {@link AbstractResponse#errorCounts()}.
clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java