Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApiClient: print stack trace when retry fails #1877

Merged
merged 1 commit into from
Aug 2, 2024
Merged
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
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