public static String formatErrors(Iterable<SoyError> errors) {
    int numErrors = 0;
    int numWarnings = 0;
    for (SoyError error : errors) {
      if (error.isWarning()) {
        numWarnings++;
      } else {
        numErrors++;
      }
    }
    if (numErrors + numWarnings == 0) {
      throw new IllegalArgumentException("cannot format 0 errors");
    }
    StringBuilder sb =
        new StringBuilder(numErrors == 0 ? "warnings" : "errors")
            .append(" during Soy compilation\n");
    Joiner.on('\n').appendTo(sb, errors);
    if (numErrors > 0) {
      formatNumber(numErrors, "error", sb);
    }
    if (numWarnings > 0) {
      if (numErrors > 0) {
        sb.append(' ');
      }
      formatNumber(numWarnings, "warning", sb);
    }
    return sb.append('\n').toString();
  }
public static String formatErrors ( Iterable < SoyError > errors ) { int numErrors = 0 ; int numWarnings = 0 ; for ( SoyError error : errors ) { if ( error . isWarning ( ) ) { numWarnings ++ ; } else { numErrors ++ ; } } if ( numErrors + numWarnings == 0 ) { throw new IllegalArgumentException ( "cannot format 0 errors" ) ; } StringBuilder sb = new StringBuilder ( numErrors == 0 ? "warnings" : "errors" ) . append ( " during Soy compilation\n" ) ; Joiner . on ( '\n' ) . appendTo ( sb , errors ) ; if ( numErrors > 0 ) { formatNumber ( numErrors , "error" , sb ) ; } if ( numWarnings > 0 ) { if ( numErrors > 0 ) { sb . append ( ' ' ) ; } formatNumber ( numWarnings , "warning" , sb ) ; } return sb . append ( '\n' ) . toString ( ) ; }
Formats the errors in a standard way for displaying to a user.