private static List getCauseStackTraceLines()

in src/main/java/org/junit/internal/Throwables.java [130:154]


    private static List<String> getCauseStackTraceLines(Throwable exception) {
        if (exception.getCause() != null || hasSuppressed(exception)) {
            String fullTrace = getFullStackTrace(exception);
            BufferedReader reader = new BufferedReader(
                    new StringReader(fullTrace.substring(exception.toString().length())));
            List<String> causedByLines = new ArrayList<String>();
    
            try {
                String line;
                while ((line = reader.readLine()) != null) {
                    if (line.startsWith("Caused by: ") || line.trim().startsWith("Suppressed: ")) {
                        causedByLines.add(line);
                        while ((line = reader.readLine()) != null) {
                            causedByLines.add(line);
                        }
                        return causedByLines;
                    }
                }
            } catch (IOException e) {
                // We should never get here, because we are reading from a StringReader
            }
        }

        return Collections.emptyList();
    }