Skip to content

Display underlying errors to the user and improve Android boot error handling#127

Merged
lfroms merged 2 commits intomainfrom
improve-error-handling
Mar 12, 2026
Merged

Display underlying errors to the user and improve Android boot error handling#127
lfroms merged 2 commits intomainfrom
improve-error-handling

Conversation

@lfroms
Copy link
Member

@lfroms lfroms commented Mar 12, 2026

What does this change accomplish?

This change accomplishes two things, both related to error handling:

  • Makes it easier to troubleshoot tooling issues by displaying failed command output to the user when appropriate.
  • Improves resiliency to failures while waiting for Android boot.

How have you achieved it?

  • By creating a new DiagnosticError type that wraps thrown errors and automatically pulls out information provided by shell command errors (currently standard error).
  • By adjusting the Android boot waiting so that the boot status checking is looped on the Swift side so that errors can be handled appropriately. A timeout for wait-for-device was also added as previously this could hang indefinitely

How can the change be tested?

Boot a few devices and ensure that they still boot as expected. Ensure that error messages that were previously displayed are still displayed (check things like invalid token, missing files, device issues, etc.) To see the new underlying errors, click "Show Details" in the error alert.

@lfroms lfroms self-assigned this Mar 12, 2026
Comment on lines +63 to +81
try await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
while true {
if try firstLine(of: .adb(.getProp(serial: serial, property: "sys.boot_completed"))) == "1" {
return
}

try await Task.sleep(for: .seconds(1))
}
}

group.addTask {
try await Task.sleep(for: .seconds(300))
throw AdbBootTimedOutError()
}

try await group.next()
group.cancelAll()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Just a very Swift-y timeout mechanism. The first task to finish wins.

@lfroms lfroms merged commit 27b9334 into main Mar 12, 2026
3 checks passed
@lfroms lfroms deleted the improve-error-handling branch March 12, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants