code: public String formatDiagnostic(JCDiagnostic d, Locale l) {
          try {
              StringBuilder buf = new StringBuilder();
              if (d.getPosition() != Position.NOPOS) {
                  buf.append(formatSource(d, false, null));
                  buf.append(':');
                  buf.append(formatPosition(d, LINE, null));
                  buf.append(':');
                  buf.append(formatPosition(d, COLUMN, null));
                  buf.append(':');
              }
              else if (d.getSource() != null && d.getSource().getKind() == JavaFileObject.Kind.CLASS) {
                  buf.append(formatSource(d, false, null));
                  buf.append(":-:-:");
              }
              else
                  buf.append('-');
              buf.append(' ');
              buf.append(formatMessage(d, null));
              if (displaySource(d)) {
                  buf.append("\n");
                  buf.append(formatSourceLine(d, 0));
              }
              return buf.toString();
          }
          catch (Exception e) {
              //e.printStackTrace();
              return null;
          }
      }
docs: provide common default formats