Skip to main content

NeonError

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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§status: u16

The status code.

§body: Box<str>

As much of the body as was kept, truncated for the message.

§

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.

Fields

§bytes: usize

The size that was refused.

§

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.

Fields

§value: i64

The rejected value.

§

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.

Fields

§column: &'static str

The column the decoder asked for.

§

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.

Fields

§position: u64

Where the unstamped row sits.

§

MalformedIdentity

An origin_store column held something other than sixteen bytes.

Fields

§len: usize

The length that was refused.

§

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

Available on crate feature 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.

Fields

§position: u64

The position the origin assigned.

§

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

Available on crate feature 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: SequencePosition

The write group the guard belongs to.

§source: GuardCodecError

Why the codec refused it.

§

UnstorableGuard

Available on crate feature 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.

Fields

§group: usize

The group’s index in the call.

§source: GuardCodecError

Why the codec refused it.

§

GroupOrder(GroupOrderError)

Available on crate feature 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.

Fields

§expected: usize

How many statements the request carried.

§actual: usize

How many result sets came back.

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.

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

The remedy this failure calls for.
§

impl<E: Debug> Debug for NeonError<E>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<E> Display for NeonError<E>

§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<E> Error for NeonError<E>
where E: Error + 'static, Self: Debug + Display,

§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
§

impl<E> From<GroupOrderError> for NeonError<E>

§

fn from(source: GroupOrderError) -> Self

Converts to this type from the input type.
§

impl<E> From<NeonSqlError> for NeonError<E>

§

fn from(source: NeonSqlError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<E> !RefUnwindSafe for NeonError<E>

§

impl<E> !UnwindSafe for NeonError<E>

§

impl<E> Freeze for NeonError<E>
where E: Freeze,

§

impl<E> Send for NeonError<E>
where E: Send,

§

impl<E> Sync for NeonError<E>
where E: Sync,

§

impl<E> Unpin for NeonError<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for NeonError<E>
where E: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.