Exceptions and Error Handling
Recommended client behavior:
- Handle library exceptions (like
BroAPIErrorfrombro.exceptions) when performing execution to catch network connectivity, API failures, or timeout issues. - For
session.execute(...), the underlying request handles HTTP codes inherently. Ensure you check the command execution dictionary return value. - Always poll the command until
doneorfailed(which is standard behavior forsession.execute()unlessawait_completion=False). - For batch results, inspect each item in
response.get("commands", []). - Handle
offloaded_data_urlwherever large outputs are possible. - Use context managers
with client.create_session(...) as session:so sessions do not keep billing if your application crashes mid-execution.
Common failure sources:
- invalid command parameters
- unsupported proxy country or city
- session expiration or user-initiated stop while a command is pending
- large responses being offloaded rather than returned inline