private void checkAndPropagateAsyncError ( ) throws Exception { if ( thrownException != null ) { String errorMessages = "" ; if ( thrownException instanceof UserRecordFailedException ) { List < Attempt > attempts = ( ( UserRecordFailedException ) thrownException ) . getResult ( ) . getAttempts ( ) ; for ( Attempt attempt : attempts ) { if ( attempt . getErrorMessage ( ) != null ) { errorMessages += attempt . getErrorMessage ( ) + "\n" ; } } } if ( failOnError ) { throw new RuntimeException ( "An exception was thrown while processing a record: " + errorMessages , thrownException ) ; } else { LOG . warn ( "An exception was thrown while processing a record: {}" , thrownException , errorMessages ) ; // reset, prevent double throwing thrownException = null ; } } }
Check if there are any asynchronous exceptions . If so rethrow the exception .