Skip to main content

Handle errors

Errors returned by the service carry the HTTP status code, a code and a human-readable message. code is the error value the gateway sends, for example snapshot_not_ready. Switch on code (Go: Code), and show the message to people.
How the SDK fills code and message:
  • If the response body has error and message, code is error and message is the text.
  • If the body has only error, both code and message are that value.
  • If the body has only message, code is empty.
  • If the body has its own code, it is kept as code.
  • Only non-empty strings are used. A body that is not a JSON object gives the message “Request failed”.
str(exc) in Python is <code>: <message>, or just the message when code is empty or equal to it. In Go, Error() returns agentbox: <code>: <message> (status=N), or agentbox: <message> (status=N) in the same cases.
Behavior change in Python 0.1.0b8 and Go v0.1.0-beta.8. Before, message held the gateway’s error value and code was set only from a code field, which the gateway does not send. Code that compared message with a value such as snapshot_not_ready must now compare code (Go: Code).
Other errors: In Python, service and connection errors derive from AgentBoxSDKError, and every service error derives from APIError. Invalid input, such as a missing API key, a relative file path, or a missing idc_name or instance_type on launch, raises a plain ValueError.
The SDK does not retry failed requests. On rate-limit or server errors, retry with backoff.

Limits

Reporting a problem

Send your GMI contact:
  • SDK language and version
  • Data center, size and image
  • Sandbox ID, and the execution ID for command issues
  • request_id and trace_id from the error response, if present, plus the HTTP status, code and message
  • Time of the issue (UTC)
  • The smallest code or command that reproduces it
Never include your API key.