Exemple #1
0
 /**
  * Returns a nice localized message for the passed exception in case it is possible, or toString()
  * otherwise.
  */
 static String getLocalizedMessage(Throwable e) {
   String localizedMessage;
   try {
     // try to load localized message
     if (e instanceof UserErrorException) {
       localizedMessage = e.getMessage();
     } else {
       String exceptionClassName = e.getClass().getSimpleName();
       String originalMessage = e.getMessage();
       localizedMessage =
           Labels.getLabel(
               "exception."
                   + exceptionClassName
                   + (originalMessage != null ? "." + originalMessage : ""));
     }
     // add cause summary, if it exists
     if (e.getCause() != null) {
       localizedMessage += "\n\n" + e.getCause().toString();
     }
     LOG.log(Level.FINE, "error", e);
   } catch (Exception e2) {
     // fallback to default text
     localizedMessage = e.toString();
     // output stack trace to the console
     LOG.log(Level.SEVERE, "unexpected error", e);
   }
   return localizedMessage;
 }
 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();
   }
 }
 private XmlUIElement getXmlUIElementFor(String typeArg) {
   if (typeToClassMappingProp == null) {
     setUpMappingsHM();
   }
   String clsName = (String) typeToClassMappingProp.get(typeArg);
   if ((clsName != null) && !(clsName.equals("*NOTFOUND*")) && !(clsName.equals("*EXCEPTION*"))) {
     try {
       Class cls = Class.forName(clsName);
       return (XmlUIElement) cls.newInstance();
     } catch (Throwable th) {
       typeToClassMappingProp.put(typeArg, "*EXCEPTION*");
       showErrorMessage(
           MessageFormat.format(
               ProvClientUtils.getString(
                   "{0} occurred when trying to get the XmlUIElement for type : {1}"),
               new Object[] {th.getClass().getName(), typeArg}));
       th.printStackTrace();
       return null;
     }
   } else if (clsName == null) {
     typeToClassMappingProp.put(typeArg, "*NOTFOUND*");
     showErrorMessage(
         MessageFormat.format(
             ProvClientUtils.getString(
                 "The type {0} does not have the corresponding XMLUIElement specified in the TypeToUIElementMapping.txt file"),
             new Object[] {typeArg}));
   }
   return null;
 }
 private void populateException(Throwable e) {
   StringBuilder builder = new StringBuilder();
   builder.append("Stack Trace:").append("\n");
   builder.append("    Exception: ").append(e.getClass().getSimpleName()).append("\n");
   builder.append("    Message: ").append(e.getMessage()).append("\n");
   logTrace(builder, e);
   errorArea.setText(builder.toString());
 }
 private void handleException(final Throwable ex) {
   // Ignore CommunicatorDestroyedException which could occur on
   // shutdown.
   if (ex instanceof com.zeroc.Ice.CommunicatorDestroyedException) {
     return;
   }
   ex.printStackTrace();
   _status.setText(ex.getClass().getName());
 }
  public static String toMessage(Throwable t) {
    String message;
    if (t.getLocalizedMessage() == null) {
      message = "No description was provided";
    } else if (t.getLocalizedMessage().toLowerCase().indexOf("side location conflict") > -1) {
      message = t.getLocalizedMessage() + " -- Check for invalid geometries.";
    } else {
      message = t.getLocalizedMessage();
    }

    return message + " (" + StringUtil.toFriendlyName(t.getClass().getName()) + ")";
  }
  private void processException(Throwable e) {
    if (e.getMessage() != null) {
      myProgress.addMessage(myDebuggerSession, MessageCategory.ERROR, e.getMessage());
    }

    if (e instanceof ProcessCanceledException) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.INFORMATION,
          DebuggerBundle.message("error.operation.canceled"));
      return;
    }

    if (e instanceof UnsupportedOperationException) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.operation.not.supported.by.vm"));
    } else if (e instanceof NoClassDefFoundError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.class.def.not.found", e.getLocalizedMessage()));
    } else if (e instanceof VerifyError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.verification.error", e.getLocalizedMessage()));
    } else if (e instanceof UnsupportedClassVersionError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.unsupported.class.version", e.getLocalizedMessage()));
    } else if (e instanceof ClassFormatError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.class.format.error", e.getLocalizedMessage()));
    } else if (e instanceof ClassCircularityError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.class.circularity.error", e.getLocalizedMessage()));
    } else {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message(
              "error.exception.while.reloading", e.getClass().getName(), e.getLocalizedMessage()));
    }
  }
 private String generateExceptionReport() {
   StringBuilder builder = new StringBuilder("Spoutcraft Launcher Error Report:\n");
   builder.append("( Please submit this report to http://spout.in/issues )\n");
   builder.append("    Launcher Build: ").append(Settings.getLauncherBuild()).append("\n");
   builder
       .append("----------------------------------------------------------------------")
       .append("\n");
   builder.append("Stack Trace:").append("\n");
   builder.append("    Exception: ").append(cause.getClass().getSimpleName()).append("\n");
   builder.append("    Message: ").append(cause.getMessage()).append("\n");
   logTrace(builder, cause);
   builder
       .append("----------------------------------------------------------------------")
       .append("\n");
   builder.append("System Information:\n");
   builder.append("    Operating System: ").append(System.getProperty("os.name")).append("\n");
   builder
       .append("    Operating System Version: ")
       .append(System.getProperty("os.version"))
       .append("\n");
   builder
       .append("    Operating System Architecture: ")
       .append(System.getProperty("os.arch"))
       .append("\n");
   builder
       .append("    Java version: ")
       .append(System.getProperty("java.version"))
       .append(" ")
       .append(System.getProperty("sun.arch.data.model", "32"))
       .append(" bit")
       .append("\n");
   builder
       .append("    Total Memory: ")
       .append(Runtime.getRuntime().totalMemory() / 1024L / 1024L)
       .append(" MB\n");
   builder
       .append("    Max Memory: ")
       .append(Runtime.getRuntime().maxMemory() / 1024L / 1024L)
       .append(" MB\n");
   builder
       .append("    Memory Free: ")
       .append(Runtime.getRuntime().freeMemory() / 1024L / 1024L)
       .append(" MB\n");
   builder
       .append("    CPU Cores: ")
       .append(Runtime.getRuntime().availableProcessors())
       .append("\n");
   return builder.toString();
 }
 /**
  * {@link RemoteUtil#unwrap(Throwable) unwraps} given exception if possible and builds error
  * message for it.
  *
  * @param e exception to process
  * @return error message for the given exception
  */
 @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"})
 @NotNull
 public static String buildErrorMessage(@NotNull Throwable e) {
   Throwable unwrapped = RemoteUtil.unwrap(e);
   String reason = unwrapped.getLocalizedMessage();
   if (!StringUtil.isEmpty(reason)) {
     return reason;
   } else if (unwrapped.getClass() == GradleApiException.class) {
     return String.format(
         "gradle api threw an exception: %s",
         ((GradleApiException) unwrapped).getOriginalReason());
   } else {
     StringWriter writer = new StringWriter();
     unwrapped.printStackTrace(new PrintWriter(writer));
     return writer.toString();
   }
 }
 /**
  * Default action when any uncaught exception bubbled from the mouse event handlers of the tools.
  * Subclass may override it to provide other action.
  */
 protected void handleMouseEventException(Throwable t) {
   JOptionPane.showMessageDialog(
       this, t.getClass().getName() + " - " + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
   t.printStackTrace();
 }
Exemple #11
0
 private void handleException(Throwable ex) {
   ex.printStackTrace();
   JOptionPane.showMessageDialog(
       this, ex.toString(), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
 }