Rust SDK · Errors
The recorder surfaces these error types:
HttpError. Non-2xx from the ingestion endpoint. Readstatus,bodyandretry_after(the server'sRetry-Afteras aDuration, zero when absent); calltransient()(5xx and 429 are flagged for retry). The struct is#[non_exhaustive], so build one withHttpError::new(status, body), for example in a custom recorder or a test, and setretry_afteron the result.RecordError. The error a recorder returns:Http,Transport(network),Timeout,BufferFull(overflow withOverflowPolicy::Error), orInnerPanic(an inner recorder panicked during a batch send). Has atransient()convenience. The enum is#[non_exhaustive], so give amatchon it a wildcard arm.DrainTimeout.close()exceededdrain_timeoutwith 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).