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()) + ")";
  }
 /**
  * {@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();
   }
 }
Exemple #3
0
 /**
  * Core constructor, init Model instances
  *
  * @param debugMode Show additional information for debugging purposes
  * @note Call startup() to init Swing
  */
 public Core(CoreWorkspaceImpl coreWorkspace, boolean debugMode, LoadingFrame splashScreen)
     throws InvocationTargetException, InterruptedException {
   ProgressMonitor parentProgress = splashScreen.getProgressMonitor();
   ProgressMonitor progressInfo = parentProgress.startTask(I18N.tr("Loading Workspace.."), 100);
   MainContext.initConsoleLogger(debugMode);
   // Declare empty main frame
   mainFrame = new MainFrame();
   // Set the main frame position and size
   mainFrame.setSize(MAIN_VIEW_SIZE);
   // Try to set the frame at the center of the default screen
   try {
     GraphicsDevice device =
         GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
     Rectangle screenBounds = device.getDefaultConfiguration().getBounds();
     mainFrame.setLocation(
         screenBounds.x + screenBounds.width / 2 - MAIN_VIEW_SIZE.width / 2,
         screenBounds.y + screenBounds.height / 2 - MAIN_VIEW_SIZE.height / 2);
   } catch (Throwable ex) {
     LOGGER.error(ex.getLocalizedMessage(), ex);
   }
   UIFactory.setMainFrame(mainFrame);
   initMainContext(debugMode, coreWorkspace, splashScreen);
   progressInfo.progressTo(10);
   this.viewWorkspace = new ViewWorkspace(this.mainContext.getCoreWorkspace());
   Services.registerService(
       ViewWorkspace.class, I18N.tr("Contains view folders path"), viewWorkspace);
   progressInfo.setTaskName(I18N.tr("Register GUI Sql functions.."));
   addSQLFunctions();
   progressInfo.progressTo(11);
   // Load plugin host
   progressInfo.setTaskName(I18N.tr("Load the plugin framework.."));
   startPluginHost();
   progressInfo.progressTo(18);
   progressInfo.setTaskName(I18N.tr("Connecting to the database.."));
   // Init database
   try {
     mainContext.initDataBase(
         coreWorkspace.getDataBaseUser(), coreWorkspace.getDataBasePassword());
   } catch (SQLException ex) {
     throw new RuntimeException(ex.getLocalizedMessage(), ex);
   }
   initSIF();
   progressInfo.progressTo(20);
 }
  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 void checkCantRun(RunConfiguration configuration, String reasonBeginning)
      throws ExecutionException {
    // MockRunRequest request = new MockRunRequest(myProject);
    // CantRunException rejectReason;
    // try {
    //  configuration.runRequested(request);
    //  rejectReason = request.myRejectReason;
    // }
    // catch (CantRunException e) {
    //  rejectReason = e;
    // }
    // if (rejectReason == null) fail("Should not run");
    // rejectReason.getMessage().startsWith(reasonBeginning);

    try {
      configuration.checkConfiguration();
    } catch (RuntimeConfigurationError e) {
      assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning));
      return;
    } catch (RuntimeConfigurationException ignored) {

    }

    RunProfileState state =
        configuration.getState(
            DefaultRunExecutor.getRunExecutorInstance(),
            new ExecutionEnvironmentBuilder(myProject, DefaultRunExecutor.getRunExecutorInstance())
                .runProfile(configuration)
                .build());
    assertTrue(state instanceof JavaCommandLine);

    try {
      ((JavaCommandLine) state).getJavaParameters();
    } catch (Throwable e) {
      assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning));
      return;
    }

    fail("Should not run");
  }
Exemple #6
0
 /**
  * Creates a new instance of MessageInf
  *
  * @param e
  */
 public MessageInf(Throwable e) {
   this(SGN_WARNING, e.getLocalizedMessage(), e);
 }