public static String stackTrace(Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        return sw.toString();
    }
Get the stack trace from an exception as a string
clients/src/main/java/org/apache/kafka/common/utils/Utils.java