public static void report ( String testId , Throwable cause ) { if ( cause == null ) { LOGGER . fatal ( "Can't call report with a null exception" ) ; return ; } long exceptionCount = FAILURE_ID . incrementAndGet ( ) ; if ( exceptionCount > MAX_EXCEPTION_COUNT ) { LOGGER . warn ( "Exception #" + exceptionCount + " detected. The maximum number of exceptions has been exceeded, so it" + " won't be reported to the Agent." , cause ) ; return ; } LOGGER . warn ( "Exception #" + exceptionCount + " detected" , cause ) ; String targetFileName = exceptionCount + ".exception" ; File dir = getUserDir ( ) ; File tmpFile = new File ( dir , targetFileName + ".tmp" ) ; try { if ( ! tmpFile . createNewFile ( ) ) { throw new IOException ( "Could not create tmp file: " + tmpFile . getAbsolutePath ( ) ) ; } } catch ( IOException e ) { LOGGER . fatal ( "Could not report exception; this means that this exception is not visible to the coordinator" , e ) ; return ; } writeText ( testId + NEW_LINE + throwableToString ( cause ) , tmpFile ) ; File file = new File ( dir , targetFileName ) ; LOGGER . info ( file . getAbsolutePath ( ) ) ; rename ( tmpFile , file ) ; }
Writes the cause to file .