use of com.intellij.execution.process.ProcessNotCreatedException in project intellij-community by JetBrains.
the class GeneralCommandLine method createProcess.
@NotNull
public Process createProcess() throws ExecutionException {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing [" + getCommandLineString() + "]");
LOG.debug(" environment: " + myEnvParams + " (+" + myParentEnvironmentType + ")");
LOG.debug(" charset: " + myCharset);
}
List<String> commands;
try {
checkWorkingDirectory();
if (StringUtil.isEmptyOrSpaces(myExePath)) {
throw new ExecutionException(IdeBundle.message("run.configuration.error.executable.not.specified"));
}
commands = CommandLineUtil.toCommandLine(myExePath, myProgramParams.getList());
} catch (ExecutionException e) {
LOG.info(e);
throw e;
}
try {
return startProcess(commands);
} catch (IOException e) {
LOG.info(e);
throw new ProcessNotCreatedException(e.getMessage(), e, this);
}
}
use of com.intellij.execution.process.ProcessNotCreatedException in project intellij-community by JetBrains.
the class ExecutionUtil method handleExecutionError.
public static void handleExecutionError(@NotNull final Project project, @NotNull final String toolWindowId, @NotNull String taskName, @NotNull ExecutionException e) {
if (e instanceof RunCanceledByUserException) {
return;
}
LOG.debug(e);
String description = e.getMessage();
if (StringUtil.isEmptyOrSpaces(description)) {
LOG.warn("Execution error without description", e);
description = "Unknown error";
}
HyperlinkListener listener = null;
if ((description.contains("87") || description.contains("111") || description.contains("206")) && e instanceof ProcessNotCreatedException && !PropertiesComponent.getInstance(project).isTrueValue("dynamic.classpath")) {
final String commandLineString = ((ProcessNotCreatedException) e).getCommandLine().getCommandLineString();
if (commandLineString.length() > 1024 * 32) {
description = "Command line is too long. In order to reduce its length classpath file can be used.<br>" + "Would you like to enable classpath file mode for all run configurations of your project?<br>" + "<a href=\"\">Enable</a>";
listener = new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
PropertiesComponent.getInstance(project).setValue("dynamic.classpath", "true");
}
};
}
}
final String title = ExecutionBundle.message("error.running.configuration.message", taskName);
final String fullMessage = title + ":<br>" + description;
if (ApplicationManager.getApplication().isUnitTestMode()) {
LOG.error(fullMessage, e);
}
if (listener == null) {
listener = ExceptionUtil.findCause(e, HyperlinkListener.class);
}
final HyperlinkListener finalListener = listener;
final String finalDescription = description;
UIUtil.invokeLaterIfNeeded(() -> {
if (project.isDisposed()) {
return;
}
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (toolWindowManager.canShowNotification(toolWindowId)) {
//noinspection SSBasedInspection
toolWindowManager.notifyByBalloon(toolWindowId, MessageType.ERROR, fullMessage, null, finalListener);
} else {
Messages.showErrorDialog(project, UIUtil.toHtml(fullMessage), "");
}
NotificationListener notificationListener = finalListener == null ? null : (notification, event) -> {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
finalListener.hyperlinkUpdate(event);
}
};
ourNotificationGroup.createNotification(title, finalDescription, NotificationType.ERROR, notificationListener).notify(project);
});
}
Aggregations