Rust SDK · Errors

The recorder surfaces these error types:

  • HttpError. Non-2xx from the ingestion endpoint. Read status, body and retry_after (the server's Retry-After as a Duration, zero when absent); call transient() (5xx and 429 are flagged for retry). The struct is #[non_exhaustive], so build one with HttpError::new(status, body), for example in a custom recorder or a test, and set retry_after on the result.
  • RecordError. The error a recorder returns: Http, Transport (network), Timeout, BufferFull (overflow with OverflowPolicy::Error), or InnerPanic (an inner recorder panicked during a batch send). Has a transient() convenience. The enum is #[non_exhaustive], so give a match on it a wildcard arm.
  • DrainTimeout. close() exceeded drain_timeout with events pending.

The buffered recorder retries transient errors itself and reports what it gives up on to on_drop, so record and flush don't return delivery errors. record returns RecordError::BufferFull under OverflowPolicy::Error. An HttpRecorder used directly returns every error to you. It takes the event by value and fills in a missing id inside the call, so fix the id with prepare before you keep a copy to retry; otherwise the retry carries a new id and is not deduplicated:

use everscribe::event;
use everscribe::recorder::RecordError;

event::prepare(&mut e); // fills id and occurred_at, so a retry reuses them
let retry = e.clone();
match http_rec.record(e).await {
    Ok(()) => {}
    Err(RecordError::Http(err)) if err.transient() => {
        // 5xx or 429: wait err.retry_after (if set), then send `retry`
    }
    Err(err) if err.transient() => {
        // network or timeout: send `retry`, which has the same event id
    }
    Err(err) => eprintln!("everscribe: {err}"),
}

The minter returns MinterError: Validation (client-side, before any HTTP call: invalid tenant_id, malformed wildcard, out-of-range expires_in), Http { status, body } (400/401/404), Transport (network), or Decode (unexpected response body).