Exceptions and Error Handling

Recommended client behavior:

  • Handle library exceptions (like BroAPIError from bro.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 done or failed (which is standard behavior for session.execute() unless await_completion=False).
  • For batch results, inspect each item in response.get("commands", []).
  • Handle offloaded_data_url wherever 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