Skip to content

Errors

Every exception the client raises, and the codes and reasons they carry. Guide: Errors.

errors

Exception hierarchy. Driver failures arrive as data (CommandResult.error) and become CommandError; server-level failures arrive as gRPC status codes and are mapped in client.py.

TapError

Bases: Exception

Base class for everything this package raises deliberately.

scan_partial

scan_partial: ScanResult | None

Detached partial observations when raised during a scan; otherwise None.

SettingsRestorationError

Bases: TapError

One or more temporary settings could not be restored.

failures contains (setting_name, exception) pairs in cleanup order. When the block or setup already failed, that original exception remains primary and this error is attached as settings_restoration_error (with a traceback note on Python 3.11+, or an error log on Python 3.10).

failures

failures

ServerError

Bases: TapError

The host server rejected or failed a call (unknown connection or device, bad argument, driver start failure, ...). code is the gRPC status code name; reason is the server's structured FailureReason, FailureReason.UNSPECIFIED when the failure did not come from the daemon.

code

code

details

details

reason

reason

CommandError

Bases: TapError

A driver command's outcome was error. code is an ErrorCode; detail refines it (e.g. NOT_FOUND/END_REACHED); TRANSPORT_LOST/INDETERMINATE carry the transmission state. A NOT_FOUND from a selector also carries narrowing: which part of the selector ruled the nodes out, which the message shows on the lines after the first.

code

code

detail

detail

driver_message

driver_message

operation

operation

serial

serial

selector

selector

request_id

request_id

generation

generation

duration_ms

duration_ms

narrowing

narrowing

Why the selector found no node, read on the device after a NOT_FOUND; None otherwise.

app_death

app_death

For AUT_CRASHED / AUT_ANR: the app's death that replaced the code; None otherwise.

AppDiedError

Bases: TapError

A watched app crashed or stopped responding during a guard() block, or during a test (the pytest plugin's end-of-test check). Each line names the device ([serial]). deaths are the deaths, oldest first; death the first. failure is what the block raised, if anything: the CommandError that carried the death, or the block's own failure. It is also the exception's __cause__.

deaths

deaths: tuple[AppDeath, ...]

The deaths, oldest first.

failure

failure

What the block (or test) raised, if anything.

death

death: AppDeath

The first death.

WaitTimeoutError

Bases: TapError

A condition did not hold within its timeout; the message names the device, the condition and what was observed so a log line alone is diagnosable: reason and match_count for the waits the device runs (visible, one, gone, the state waits, App.await_visible, App.await_screen_stable), last_state for a state wait whose node never reached the state, last_observation and polls for the ones the client polls.

description

description

serial

serial

elapsed_ms

elapsed_ms

polls

polls

last_observation

last_observation

reason

reason

Why the device-side condition was still unmet at its last poll; None for client-polled waits.

match_count

match_count

Matches at the last poll of visible / one / gone (capped at 1000).

last_state

last_state

A state wait's node as the device read it at the end (reason STATE_NOT_REACHED); None otherwise.

condition_parts

condition_parts

With STATE_NOT_REACHED: each part of the condition on that same node, and whether it held. Empty otherwise.

narrowing

narrowing

With reason NO_MATCH from visible / one / a state wait: which part of the selector ruled the nodes out, read after the deadline. None otherwise.

AppDataError

Bases: TapError

Private-app data was refused/failed. detail is a stable server token (e.g. APP_RUNNING, SYMLINK, EXISTS); serial identifies the device. Never relaunch or retry an interrupted database import blindly.

detail

detail

serial

serial

AppLifecycleError

Bases: TapError

Install/launch/stop did not reach the verified end state.

DeviceBusyError

Bases: TapError

Another session — in this process or any other — holds the device, and wait_for_device was zero or ran out. The device is fine; try later or pick another serial.

DeviceQuarantinedError

Bases: TapError

The device's session journal keeps it out of service (a mutation whose outcome could not be proven, a corrupt journal, an uncertain ADB cleanup). It stays unusable until an explicit reset; retrying or waiting does not help.

serial

serial

ErrorCode

Bases: Enum

Why a driver command failed (CommandError.code). UNKNOWN also stands for a code this client version does not know.

INVALID_REQUEST

INVALID_REQUEST

INVALID_SELECTOR

INVALID_SELECTOR

UNSUPPORTED

UNSUPPORTED

UNAUTHENTICATED

UNAUTHENTICATED

SESSION_MISMATCH

SESSION_MISMATCH

DUPLICATE_OR_STALE

DUPLICATE_OR_STALE

OVERLOADED

OVERLOADED

AUT_MISMATCH

AUT_MISMATCH

NOT_FOUND

NOT_FOUND

AMBIGUOUS

AMBIGUOUS

NOT_INTERACTABLE

NOT_INTERACTABLE

STALE_BEFORE_INPUT

STALE_BEFORE_INPUT

STALE_DURING_COMMAND

STALE_DURING_COMMAND

ACTION_REJECTED

ACTION_REJECTED

WAIT_TIMEOUT

WAIT_TIMEOUT

CANCELLED

CANCELLED

DEADLINE_EXCEEDED

DEADLINE_EXCEEDED

AUT_NOT_INSTALLED

AUT_NOT_INSTALLED

AUT_CRASHED

AUT_CRASHED

AUT_ANR

AUT_ANR

SYNC_PROVIDER_UNAVAILABLE

SYNC_PROVIDER_UNAVAILABLE

DRIVER_UNHEALTHY

DRIVER_UNHEALTHY

TRANSPORT_LOST

TRANSPORT_LOST

INDETERMINATE

INDETERMINATE

ARTIFACT_TRANSFER_FAILED

ARTIFACT_TRANSFER_FAILED

PAYLOAD_TOO_LARGE

PAYLOAD_TOO_LARGE

INTERNAL

INTERNAL

UNKNOWN

UNKNOWN

FailureReason

Bases: Enum

The server's structured reason for a failed call (ServerError.reason). UNSPECIFIED means the failure did not come from the daemon (a transport failure, a proxy, a cancelled call) or carried a reason this client version does not know.

UNSPECIFIED

UNSPECIFIED

INTERNAL

INTERNAL

INVALID_ARGUMENT

INVALID_ARGUMENT

UNAUTHENTICATED

UNAUTHENTICATED

UNKNOWN_CLIENT_CONNECTION

UNKNOWN_CLIENT_CONNECTION

UNKNOWN_ATTACHED_DEVICE

UNKNOWN_ATTACHED_DEVICE

NOT_OWNER

NOT_OWNER

DEVICE_BUSY

DEVICE_BUSY

DEVICE_QUARANTINED

DEVICE_QUARANTINED

HOST_WAIT_TIMEOUT

HOST_WAIT_TIMEOUT

ADB_TIMEOUT

ADB_TIMEOUT

ADB_FAILED

ADB_FAILED

ADB_REAP_UNCERTAIN

ADB_REAP_UNCERTAIN

APP_LIFECYCLE

APP_LIFECYCLE

DRIVER_BUILD_MISMATCH

DRIVER_BUILD_MISMATCH

DRIVER_START_FAILED

DRIVER_START_FAILED

DRIVER_TRANSPORT

DRIVER_TRANSPORT

DRIVER_COMMAND

DRIVER_COMMAND

SESSION_UNUSABLE

SESSION_UNUSABLE

DAEMON_PRECONDITION

DAEMON_PRECONDITION

UNKNOWN_REF

UNKNOWN_REF

UNKNOWN_LOG_MARKER

UNKNOWN_LOG_MARKER

REF_NOT_ADDRESSABLE

REF_NOT_ADDRESSABLE

UNSUPPORTED_API

UNSUPPORTED_API

The device's API level is too low for the call (detail REQUIRES_API_<n>).

DEVICE_SETTING

DEVICE_SETTING

A device setting did not read back as written (or could not be restored).

APP_DATA

APP_DATA

Debuggable-app data was refused or failed; AppDataError.detail identifies why.

DEVICE_FILE

DEVICE_FILE

A device file was not written or read as asked: it exists and this device handle did not create it, its directory is missing, it is not a regular file, or it did not read back.

WaitReason

Bases: Enum

Why a device-side wait timed out (WaitTimeoutError.reason).

NO_MATCH

NO_MATCH

visible / one / a state wait: nothing matched.

AMBIGUOUS

AMBIGUOUS

one: several nodes matched (WaitTimeoutError.match_count says how many).

STILL_PRESENT

STILL_PRESENT

gone: the selector still matched.

STATE_NOT_REACHED

STATE_NOT_REACHED

A state wait (enabled, checked, text_equals, ...): the node was there but never in that state (WaitTimeoutError.last_state is how it was at the end).

SCREEN_CHANGING

SCREEN_CHANGING

await_screen_stable: the screen kept changing.

APP_NOT_VISIBLE

APP_NOT_VISIBLE

App.await_visible / App.await_screen_stable: the package never owned the focused window.

NO_PERMISSION_PROMPT

NO_PERMISSION_PROMPT

await_permission_prompt: no runtime-permission dialog showed a known choice.

NO_TOAST

NO_TOAST

await_toast: no matching toast was shown.

NO_NOTIFICATION

NO_NOTIFICATION

await_notification: no matching notification was active.