protected String formatErrorMessage ( File inputFile , Throwable exception ) { File filename ; int lineno = 0 ; final boolean addExceptionName ; if ( exception instanceof ParsingException ) { addExceptionName = false ; final ParsingException pexception = ( ParsingException ) exception ; final File file = pexception . getFile ( ) ; if ( file != null ) { filename = file ; } else { filename = inputFile ; } lineno = pexception . getLineno ( ) ; } else { addExceptionName = true ; filename = inputFile ; } for ( final String sourceDir : this . session . getCurrentProject ( ) . getCompileSourceRoots ( ) ) { final File root = new File ( sourceDir ) ; if ( isParentFile ( filename , root ) ) { try { filename = FileSystem . makeRelative ( filename , root ) ; } catch ( IOException exception1 ) { // } break ; } } final StringBuilder msg = new StringBuilder ( ) ; msg . append ( filename . toString ( ) ) ; if ( lineno > 0 ) { msg . append ( ":" ) . append ( lineno ) ; //$NON-NLS-1$ } msg . append ( ": " ) ; //$NON-NLS-1$ final Throwable rootEx = Throwables . getRootCause ( exception ) ; if ( addExceptionName ) { msg . append ( rootEx . getClass ( ) . getName ( ) ) ; msg . append ( " - " ) ; //$NON-NLS-1$ } msg . append ( rootEx . getLocalizedMessage ( ) ) ; return msg . toString ( ) ; }
Format the error message .