示例#1
0
 private String getFormattedStackTrace(StackTraceElement[] stacktrace) {
   StringBuilder sb = new StringBuilder();
   for (StackTraceElement element : stacktrace) {
     sb.append(element.toString()).append("\n");
   }
   return sb.toString();
 }
 private void logTrace(StringBuilder builder, Throwable e) {
   Throwable parent = e;
   String indent = "    ";
   while (parent != null) {
     if (parent == e) {
       builder.append(indent).append("Trace:").append("\n");
     } else {
       builder
           .append(indent)
           .append("Caused By: (")
           .append(parent.getClass().getSimpleName())
           .append(")")
           .append("\n");
       builder
           .append(indent)
           .append("    ")
           .append("[")
           .append(parent.getMessage())
           .append("]")
           .append("\n");
     }
     for (StackTraceElement ele : e.getStackTrace()) {
       builder.append(indent).append("    ").append(ele.toString()).append("\n");
     }
     indent += "    ";
     parent = parent.getCause();
   }
 }
示例#3
0
  /**
   * Shows an alert dialog for when an exception occurs.
   *
   * @param e the exception to show
   * @param title the title of the dialog
   */
  public static void debug(Exception e, String title) {
    e.printStackTrace();
    String text = "<i>" + e.toString() + "</i><br>";
    // add stack trace
    for (StackTraceElement ste : e.getStackTrace()) {
      text += ste.toString() + "<br>";
    }
    text += "<br><b>Please take a screenshot and email it to <u>[email protected]</u>.</b>";

    showDialog(null, "<html>Sorry! Cabra has encountered an error. Details:<br><br>" + text, title);
  }
示例#4
0
  @Override
  public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    try {
      throw new Exception();
    } catch (Exception exc) {
      StringBuffer sb = new StringBuffer();
      StackTraceElement[] stack = exc.getStackTrace();
      int count = 0;
      for (StackTraceElement stackEntry : stack) {
        if (count++ > 8) break;
        sb.append("\t");
        sb.append(stackEntry.getClassName() + ".");
        sb.append(stackEntry.getMethodName() + " [");
        sb.append(stackEntry.getLineNumber() + "]");
        sb.append("\n");
      }
      System.out.println("**** Repaint stack ****");
      System.out.println(sb.toString());
    }

    super.addDirtyRegion(c, x, y, w, h);
  }
 protected boolean isLiableToEDTRule(StackTraceElement element) throws Exception {
   return Component.class.isAssignableFrom(Class.forName(element.getClassName()));
 }