diff options
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java | 4 | ||||
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java index d074915a023..3a848b33c76 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java @@ -281,12 +281,12 @@ public abstract class ControllerHttpClient { if (response.statusCode() / 100 == 4) throw new IllegalArgumentException("Bad request for " + request + ": " + message); - throw new IOException("Failed " + request + ": " + message); + throw new IOException(message); } catch (IOException e) { // Catches the above, and timeout exceptions from the client. if (thrown == null) - thrown = new UncheckedIOException(e); + thrown = new UncheckedIOException("Failed " + request + ": " + e, e); else thrown.addSuppressed(e); diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java index 8cfbfd204ba..7119bde7a09 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java @@ -4,6 +4,7 @@ package ai.vespa.hosted.plugin; import ai.vespa.hosted.api.ControllerHttpClient; import ai.vespa.hosted.api.Properties; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.yolean.Exceptions; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -15,6 +16,10 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.joining; /** * Base class for hosted Vespa plugin mojos. @@ -61,7 +66,11 @@ public abstract class AbstractVespaMojo extends AbstractMojo { throw e; } catch (Exception e) { - throw new MojoExecutionException("Execution failed for application " + name(), e); + String message = "Execution failed for application " + name() + ":\n" + Exceptions.toMessageString(e); + if (e.getSuppressed().length > 0) + message += "\nSuppressed:\n" + Stream.of(e.getSuppressed()).map(Exceptions::toMessageString).collect(joining("\n")); + + throw new MojoExecutionException(message, e); } } |