Skip to content

on_error

Runs in the client Sends nothing to the robot

Set a function to call when the robot sends an error event. The function receives the event, a dict with code and message, for an error message from the robot that answers no command: its refusal of this computer (FORBIDDEN) and a line it could not read (BAD_JSON). Other errors reach a program through the answers to its commands, wait_idle(), the status (errors(), on_status_change()) and on_motion_error(). A client has one such function: a new call replaces it, and None removes it.

Syntax

robot.on_error(fn)

Arguments

Name Type Default Description
fn Callable[[dict], None] required The function, called with the event dict. None removes it.

Returns

Nothing.

Examples

robot.on_error(lambda event: print("robot error:", event))

Further details

Note

The function runs on the client's callback thread, one call at a time, in the order the events arrived, so a command or a wait called from it works. Keep it short: the next events wait for it. If the function raises, the client prints the exception and goes on.

See also