]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5643 Unwrap exception to have better error reporting to end user
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 6 Oct 2014 14:50:49 +0000 (16:50 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 6 Oct 2014 14:52:28 +0000 (16:52 +0200)
plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameCommand.java

index 71bec9fd21432cc3635c22c03957125b004587cf..eb258af83adee6de5fbdf02fe6d789508a962e15 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.scm.BlameCommand;
 import org.sonar.api.batch.scm.BlameLine;
 import org.sonar.api.utils.command.Command;
+import org.sonar.api.utils.command.CommandException;
 import org.sonar.api.utils.command.CommandExecutor;
 import org.sonar.api.utils.command.StreamConsumer;
 import org.sonar.api.utils.command.StringStreamConsumer;
@@ -71,6 +72,7 @@ public class SvnBlameCommand implements BlameCommand, BatchComponent {
       try {
         task.get();
       } catch (ExecutionException e) {
+        // Unwrap ExecutionException
         throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new IllegalStateException(e.getCause());
       } catch (InterruptedException e) {
         // Ignore
@@ -85,8 +87,13 @@ public class SvnBlameCommand implements BlameCommand, BatchComponent {
         Command cl = createCommandLine(fs.baseDir(), filename);
         SvnBlameConsumer consumer = new SvnBlameConsumer(filename);
         StringStreamConsumer stderr = new StringStreamConsumer();
-
-        int exitCode = execute(cl, consumer, stderr);
+        int exitCode;
+        try {
+          exitCode = execute(cl, consumer, stderr);
+        } catch (CommandException e) {
+          // Unwrap CommandException
+          throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new IllegalStateException(e.getCause());
+        }
         if (exitCode != 0) {
           throw new IllegalStateException("The svn blame command [" + cl.toString() + "] failed: " + stderr.getOutput());
         }