From 58facb9f87eed056992abbeb8a2cd0edcb791647 Mon Sep 17 00:00:00 2001 From: Thi Doan Date: Mon, 7 Mar 2022 05:36:09 -0800 Subject: [PATCH] Do not hide BulkTransferException messages when there were more than one exception Previously, when there were more than one BulkTransferException, it would be reported like this: ``` Executing genrule //:foo failed: Exec failed due to IOException: 221 errors during bulk transfer ``` which didn't include the underlying exception messages. The only case that underlying exceptions were included was when there was only one exception. This change patches the error message to include all the exception messages, which helps diagnose BulkTransferException. Closes #14981. PiperOrigin-RevId: 432921283 (cherry picked from commit 113eaca5862c48797654ae2a3acbb6e15d761485) --- .../build/lib/remote/common/BulkTransferException.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/common/BulkTransferException.java b/src/main/java/com/google/devtools/build/lib/remote/common/BulkTransferException.java index a70f4d66d3cac2..723151462912a6 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/common/BulkTransferException.java +++ b/src/main/java/com/google/devtools/build/lib/remote/common/BulkTransferException.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.remote.common; +import com.google.common.base.Joiner; import java.io.IOException; /** @@ -57,6 +58,9 @@ public String getMessage() { if (super.getSuppressed().length == 1) { return super.getSuppressed()[0].getMessage(); } - return String.format("%d errors during bulk transfer", super.getSuppressed().length); + String errorSummary = + String.format("%d errors during bulk transfer:", super.getSuppressed().length); + String combinedSuberrors = Joiner.on('\n').join(super.getSuppressed()); + return Joiner.on('\n').join(errorSummary, combinedSuberrors); } }