Skip to content

Commit f43d461

Browse files
authored
Backport to branch-1.1: Try to improve error message for server error (#695)
* backport c9554e7 * use e.getMessage
1 parent b06bfdc commit f43d461

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

client/src/main/scala/io/delta/sharing/client/DeltaSharingClient.scala

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,20 @@ class DeltaSharingRestClient(
11321132
}
11331133
} catch {
11341134
case e: org.apache.http.ConnectionClosedException =>
1135-
val error = s"Request to delta sharing server failed" + getDsQueryIdForLogging +
1136-
s" due to ${e}."
1137-
logError(error)
1138-
lineBuffer += error
1135+
logError(s"Request to delta sharing server failed$getDsQueryIdForLogging " +
1136+
s"due to ${e}.")
1137+
// takeRight(3) is safe even if the lineBuffer is empty or has fewer than 3 lines.
1138+
val linesToLog = lineBuffer.takeRight(3).mkString("\n")
1139+
logError("Last 3 lines:" + linesToLog)
1140+
1141+
val error = s"Request to delta sharing server failed$getDsQueryIdForLogging " +
1142+
s"due to ${e.getMessage}."
1143+
if (lineBuffer.nonEmpty) {
1144+
val lastIndex = lineBuffer.length - 1
1145+
lineBuffer(lastIndex) = (error + lineBuffer(lastIndex)).replace(' ', '_')
1146+
} else {
1147+
lineBuffer += error.replace(' ', '_')
1148+
}
11391149
lineBuffer.toList
11401150
} finally {
11411151
input.close()

0 commit comments

Comments
 (0)