A failed command answers with error in place of result. error.data.kind names the kind: branch on it, never on the message text. retryable says whether sending the same command again can succeed.
{ "id": 7, "error": { "code": -32009, "message": "no element matched the locator within 5000 ms",
  "data": { "kind": "ActionTimeout", "retryable": false } } }
KindCodeRetryablePython exception
UnknownOp-32601NoUnsupportedError
InvalidArgs-32602NoInvalidArgsError
Internal-32603NoHalyardError
NoAllocation-32001NoNotConnectedError
NotConnected-32002NoNotConnectedError
DeviceOffline-32004YesNotConnectedError
Timeout-32006YesTimeoutError
Unauthorized-32007NoUnauthorizedError
Canceled-32008NoHalyardError
ActionTimeout-32009NoTimeoutError
StrategyUnavailable-32010NoUnsupportedError
TreeUnavailable-32011NoTreeUnavailableError
StaleNode-32012NoStaleNodeError
TargetNotFound-32013NoTargetNotFoundError
NavigationFailed-32014NoNavigationError
EventsExpired-32015NoHalyardError
DialogOpen-32016NoDialogOpenError
Conflict-32017NoConflictError
A script that throws inside Page.evaluate, Locator.evaluate or Page.waitForFunction is not a DCP error: the command succeeds with exception in its result, and the Python SDK raises EvaluationError.