class CglibThrowableRenderer implements ThrowableRenderer {

    @Override
    public String[] doRender(Throwable th) {
        List<String> lines = new ArrayList<String>();
        lines.add(th.toString());
        addStackTraceToList(th, lines, 0);
        do {
            th = th.getCause();
            if (th != null) {
                lines.add("Caused by: " + th.toString());
                addStackTraceToList(th, lines, MAX_NUMBER_OF_STACK_TRACES_ON_LOG_FOR_CAUSE);
            }
        } while (th != null);
        return lines.toArray(new String[lines.size()]);
    }

}