Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ object RestRetryInterceptor : Interceptor {

if (response.failed) {
val code = response.code
val body = response.body?.string()
throw RuntimeException("status code: $code\nbody: $body")
val contentType = response.body?.contentType()
response.close()
throw RuntimeException("status code: $code, content-type: $contentType")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body was deliberately removed from the exception message (previously it was included). This is a silent behavior change: callers that catch and log RuntimeException — or test frameworks that only capture the exception trace — will no longer see the response body. The println on line 45 helps when stdout is captured, but that isn't guaranteed in all CI environments.

Consider including at least the (possibly truncated) body in the message so the information travels with the exception:

throw RuntimeException("status code: $code, content-type: $contentType, body: ${body?.take(500)}")

If the motivation for removing it was to avoid giant messages, a truncation strategy like this gives the best of both worlds.

}

return response
Expand Down
Loading