code: protected void writeDiagnostic(JCDiagnostic diag) {
          if (diagListener != null) {
              diagListener.report(diag);
              return;
          }
  
          PrintWriter writer = getWriterForDiagnosticType(diag.getType());
  
          printRawLines(writer, diagFormatter.format(diag, messages.getCurrentLocale()));
  
          if (promptOnError) {
              switch (diag.getType()) {
              case ERROR:
              case WARNING:
                  prompt();
              }
          }
  
          if (dumpOnError)
              new RuntimeException().printStackTrace(writer);
  
          writer.flush();
      }
docs: Write out a diagnostic.