Skip to main content
In production, some calls will fail. The network might drop for a moment, you might reach a limit, or a sandbox might already have been deleted. Handling errors well mostly comes down to one decision: should your code try again, or should it stop and fix something? This page gives you what you need to make that decision in code.

Every error looks the same

Whatever goes wrong, Fibre answers with the same kind of JSON, so you can handle every error in one place:
response
In the SDKs, every error is a FibreError with status, code, requestId and docsUrl (request_id and docs_url in Python). Each kind of error also has its own class, so you can catch only the ones you care about:

Retry, or not?

The HTTP status tells you which kind of problem you have, and whether trying again can help: The SDKs already retry for you. When a connection drops, or Fibre answers 429, 502, 503 or 504, the SDK tries again twice, waiting a little longer each time, as long as the call is safe to repeat. To change how many times, use new Fibre({ maxRetries }), or Fibre(max_retries=…) in Python.

Retrying a create safely

One case needs special care: a request to create a sandbox that times out. You cannot tell whether the sandbox was created or not, and simply trying again could create a second one that you pay for. To avoid that, send an Idempotency-Key header. If you retry with the same key, Fibre returns the first sandbox instead of creating another:
curl
  • Base the key on what you are creating, for example user-42-task-7, or a random ID that you store with the job.
  • A key is remembered for 24 hours. Using the same key with a different request is refused (422 idempotency_key_reused).
  • In the SDKs, Sandbox.create() sends a key for you, so the SDK’s own retries never create a second sandbox.
There is more about this in retry without making two.

A retry helper

If you make calls outside the SDK, or want to wait longer than its built-in retries do, a small helper like this one retries temporary errors and gives up on everything else:

Limits

Here is every limit in one place:

All error codes

Every error code, its HTTP status and what it means.

Usage and billing

See how close you are to your plan’s limits today.