Enum NeonError
#[non_exhaustive]pub enum NeonError<E> {
Show 19 variants
Transport(E),
Http {
status: u16,
body: Box<str>,
},
Sql(NeonSqlError),
ResponseTooLarge {
bytes: usize,
limit: usize,
},
MalformedResponse(Error),
InvalidPosition {
value: i64,
},
MissingColumn {
column: &'static str,
},
StoredEventType(InvalidEventType),
StoredTag(InvalidTag),
UnstampedEvent {
position: u64,
},
MalformedIdentity {
len: usize,
},
MalformedPayload,
ForeignBatch,
OriginPositionOutOfRange {
position: u64,
},
MissingIdentity,
StoredGuard {
first: SequencePosition,
source: GuardCodecError,
},
UnstorableGuard {
group: usize,
source: GuardCodecError,
},
GroupOrder(GroupOrderError),
ResultSets {
expected: usize,
actual: usize,
},
}Expand description
How a Neon-backed store fails for its own reasons.
Generic over the transport’s error so that the transport’s own failure mode
survives intact rather than being flattened into a string — the crate does
not know whether it is wrapping a reqwest::Error, a JsValue stringified
by wasm-bindgen, or a test double.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Transport(E)
No HTTP answer was obtained: DNS, TLS, a rejected fetch, a timeout.
The one variant on which a retry is unsafe without an idempotency key: a request that timed out may still have committed, and with no session there is nothing to ask.
Http
The endpoint answered with a non-2xx status and no parsable Neon error body — a gateway, an auth failure, a rate limit.
Fields
Sql(NeonSqlError)
Postgres rejected the statement, and said why.
ResponseTooLarge
The response body exceeded the endpoint’s hard cap.
There is no cursor and no continuation token, so this is terminal for the
read that produced it: the only recovery is a narrower query or a smaller
ReadOptions::limit, both of
which are new round trips against a new snapshot.
MalformedResponse(Error)
The body was 2xx JSON but not the shape this adapter asked for.
InvalidPosition
A position column held a value SequencePosition cannot represent.
The column is bigint, which is signed and admits zero, against a
NonZeroU64 — so the conversion is fallible and the failure has to be
nameable. The rejected alternative is unsigned_abs(), which reads like a
guard and turns a stored -3 into position 3.
MissingColumn
The response was well-formed JSON of the right shape and did not carry a column the decoder needs.
Distinct from MalformedResponse, which is a
serde_json failure against the wire types. This one is the adapter’s own
SELECT and its own decoder disagreeing, which is a bug in this crate
rather than a drift at the endpoint — and the two send a reader to very
different places.
StoredEventType(InvalidEventType)
A stored event_type no longer satisfies the contract’s validation.
Reachable only from a row this adapter did not write, or from validation tightening under a store that already holds data. A named variant rather than a panic, because the alternative to a variant is a panic in a library.
StoredTag(InvalidTag)
A stored tag no longer satisfies the contract’s validation.
UnstampedEvent
A row carries no EventId, so the store cannot say what it is.
origin_store and origin_position are nullable because a replication
ingest may hold rows minted elsewhere before this store stamps its own.
A row this store wrote always has both — unless migration 1’s
store_meta row is absent, which is the reachable cause and is why this
is not spelled as a decode failure.
MalformedIdentity
An origin_store column held something other than sixteen bytes.
MalformedPayload
A bytea column did not arrive as the base64 this adapter asked for.
Every SELECT here spells encode(col, 'base64') explicitly, so this is
the endpoint and this crate disagreeing rather than a caller’s data being
wrong.
ForeignBatch
A projection batch was begun on a different store instance.
rollback is the one method on the projection port whose error type is
the adapter’s rather than a dedicated enum, so the refusal
CommitError::ForeignBatch
and
ResetError::ForeignBatch
spell has to be nameable here too. The batch is consumed either way, on
this error as on success. The refusal is how a caller learns it was
holding the wrong one, on the call that was meant to be the cleanup,
which is why it cannot be left unnamed.
OriginPositionOutOfRange
sync only.A replicated event’s origin position does not fit the bigint column
that holds it.
Refused rather than saturated, because on the ingest path a position is
half an EventId: two such events from one
origin would collapse onto one stored identity and the second would be
counted as a re-delivery. Produced only by ingest, behind sync; the
enum is #[non_exhaustive], so the feature adds it additively.
MissingIdentity
The store’s meta table holds no identity row, so there is no identity to stamp an event, ingest or re-mint under. Migration 1 inserts it; its absence is a schema that was never migrated.
An append and an ingest refuse with it, and write nothing, rather than
committing rows with a NULL origin that no read could turn back into
events (UnstampedEvent), and
NeonEventStore::remint_identity refuses with it rather than creating
the row. Not behind sync, because an append produces it in every
build.
StoredGuard
sync only.A stored write-group guard is not one this build’s codec reads (#420):
the bytes in group_guard on the group’s first row, which only a
damaged schema or a newer build’s format holds. The group is not
forwarded without it. Behind sync, for the reason
OriginPositionOutOfRange is.
Fields
first: SequencePositionThe write group the guard belongs to.
source: GuardCodecErrorWhy the codec refused it.
UnstorableGuard
sync only.An ingested group’s guard could not be encoded for storage (#420).
Refused before the request is built, so nothing in the call was sent;
the group has no position yet, so it is named by its index in the
call. Behind sync, for the reason
OriginPositionOutOfRange is.
GroupOrder(GroupOrderError)
sync only.The group read handed its page builder a row naming a write group it
had already passed, so the log cannot be paged in whole groups. The read
orders its rows by group, so no schema this adapter wrote produces one;
a hand-edited write_group can. Behind sync, for the reason
OriginPositionOutOfRange is.
ResultSets
A batch answered with a different number of result sets than it sent statements (#131). The endpoint answers one result set per statement, so this is this crate and the endpoint disagreeing about the shape of an answer, and the same request fails the same way again. Declared last, so the lines above keep the numbers they are cited by.
Trait Implementations§
§impl<E> Classify for NeonError<E>
Available on crate features event-store and sync only.SY-36’s class for each way this adapter fails.
impl<E> Classify for NeonError<E>
event-store and sync only.SY-36’s class for each way this adapter fails.
Exhaustive over this crate’s own enum, with no wildcard, so a new variant does not compile until somebody decides its class. Every decoding variant is a corrupt store, a missing schema, or this crate and the endpoint disagreeing, and fails the same way again.
§fn class(&self) -> FailureClass
fn class(&self) -> FailureClass
§impl<E> Error for NeonError<E>
impl<E> Error for NeonError<E>
§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()