From 4b8fc07bc794a5a84e9ccd8e2bc630a5e3ddafa1 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 15 Jan 2013 12:33:49 +0100 Subject: [PATCH] IDEA-98218 (diagnostic) --- .../configurations/GeneralCommandLine.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java index 45c59560855d..4235cc071af7 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.execution.configurations; import com.intellij.execution.ExecutionException; import com.intellij.execution.process.ProcessNotCreatedException; import com.intellij.ide.IdeBundle; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.UserDataHolder; @@ -48,6 +49,8 @@ import java.util.Map; public class GeneralCommandLine implements UserDataHolder { public static Key DO_NOT_ESCAPE_QUOTES = Key.create("GeneralCommandLine.do.not.escape.quotes"); + private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.GeneralCommandLine"); + private String myExePath = null; private File myWorkDirectory = null; private Map myEnvParams = null; @@ -187,22 +190,34 @@ public class GeneralCommandLine implements UserDataHolder { } public Process createProcess() throws ExecutionException { - checkWorkingDirectory(); + if (LOG.isDebugEnabled()) { + LOG.debug("Executing [" + getCommandLineString() + "]"); + } - final String[] commands = prepareCommands(); - if (StringUtil.isEmptyOrSpaces(commands[0])) { - throw new ExecutionException(IdeBundle.message("run.configuration.error.executable.not.specified")); + String[] commands; + try { + checkWorkingDirectory(); + + commands = prepareCommands(); + if (StringUtil.isEmptyOrSpaces(commands[0])) { + throw new ExecutionException(IdeBundle.message("run.configuration.error.executable.not.specified")); + } + } + catch (ExecutionException e) { + LOG.warn(e); + throw e; } try { - final ProcessBuilder builder = new ProcessBuilder(commands); - final Map environment = builder.environment(); + ProcessBuilder builder = new ProcessBuilder(commands); + Map environment = builder.environment(); setupEnvironment(environment); builder.directory(myWorkDirectory); builder.redirectErrorStream(myRedirectErrorStream); return builder.start(); } catch (IOException e) { + LOG.warn(e); throw new ProcessNotCreatedException(e.getMessage(), e, this); } } @@ -212,8 +227,7 @@ public class GeneralCommandLine implements UserDataHolder { return; } if (!myWorkDirectory.exists()) { - throw new ExecutionException( - IdeBundle.message("run.configuration.error.working.directory.does.not.exist", myWorkDirectory.getAbsolutePath())); + throw new ExecutionException(IdeBundle.message("run.configuration.error.working.directory.does.not.exist", myWorkDirectory.getAbsolutePath())); } if (!myWorkDirectory.isDirectory()) { throw new ExecutionException(IdeBundle.message("run.configuration.error.working.directory.not.directory"));