public synchronized Collection < ExceptionLine > parse ( final Collection < String > input ) throws ExceptionParseException { this . parsedLines . clear ( ) ; final Queue < String > linesFromInput = ExceptionParser . removePrefix ( new LinkedList <> ( input ) ) ; LineType previousLineType = LineType . PRE_START ; String currentLine = null ; boolean isFirstLine = true ; while ( ! linesFromInput . isEmpty ( ) ) { currentLine = linesFromInput . poll ( ) ; previousLineType = this . parseLine ( previousLineType , currentLine ) ; if ( isFirstLine ) { if ( ! previousLineType . isAcceptableAsFirstLine ( ) ) { throw new ExceptionParseException ( currentLine , "Invalid line type detected at the beginning: " + previousLineType ) ; } isFirstLine = false ; } } if ( ! previousLineType . isAcceptableAsLastLine ( ) ) { throw new ExceptionParseException ( currentLine , "Invalid line type detected at the end: " + previousLineType ) ; } return Collections . unmodifiableCollection ( new LinkedList <> ( this . parsedLines ) ) ; }
Browsers through a random log and returns first exception stack trace it could find .