Esempio n. 1
0
  public static String getExceptionStack(Throwable t) {
    StringBuffer buf = new StringBuffer();
    // get exception stack
    List exceptions = getExceptionsAsList(t);

    int i = 1;
    for (Iterator iterator = exceptions.iterator(); iterator.hasNext(); i++) {
      if (i > exceptionThreshold && exceptionThreshold > 0) {
        buf.append("(").append(exceptions.size() - i + 1).append(" more...)");
        break;
      }
      Throwable throwable = (Throwable) iterator.next();
      ExceptionReader er = getExceptionReader(throwable);
      buf.append(i).append(". ").append(er.getMessage(throwable)).append(" (");
      buf.append(throwable.getClass().getName()).append(")\n");
      if (verbose && throwable.getStackTrace().length > 0) {
        StackTraceElement e = throwable.getStackTrace()[0];
        buf.append("  ")
            .append(e.getClassName())
            .append(":")
            .append(e.getLineNumber())
            .append(" (")
            .append(getJavaDocUrl(throwable.getClass()))
            .append(")\n");
      }
    }
    return buf.toString();
  }
Esempio n. 2
0
 public static String writeException(Throwable t) {
   ExceptionReader er = getExceptionReader(t);
   StringBuffer msg = new StringBuffer();
   msg.append(er.getMessage(t)).append(". Type: ").append(t.getClass());
   return msg.toString();
 }