Skip to content

Commit

Permalink
ApiClient: print stack trace when retry fails (#1877)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia authored Aug 2, 2024
1 parent 702b184 commit a240265
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions maestro-cli/src/main/java/maestro/cli/api/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ class ApiClient(

val body = bodyBuilder.build()

fun retry(message: String): UploadResponse {
fun retry(message: String, e: Throwable? = null): UploadResponse {
if (completedRetries >= maxRetryCount) {
e?.printStackTrace()
throw CliError(message)
}

PrintUtils.message("$message, retrying...")
PrintUtils.message("$message, retrying (${completedRetries+1}/$maxRetryCount)...")
Thread.sleep(BASE_RETRY_DELAY_MS + (2000 * completedRetries))

return upload(
Expand Down Expand Up @@ -333,7 +334,7 @@ class ApiClient(

client.newCall(request).execute()
} catch (e: IOException) {
return retry("Upload failed due to socket exception")
return retry("Upload failed due to socket exception", e)
}

response.use {
Expand Down

0 comments on commit a240265

Please sign in to comment.