Skip to main content

abort_kind

Function abort_kind 

Source
pub fn abort_kind(err: &Error) -> AbortKind
Expand description

Recognise a schema guard’s RAISE(ABORT, …).

The only place in the crate that matches on engine error text, and since 0.15.19 the text is reached only after the code says a trigger raised it. SQLite flattens every RAISE(ABORT) into one constraint failure, so the message remains the only thing distinguishing “you violated the single-open-interval rule” from “you violated the cross-lineage rule” — but it no longer has to distinguish a guard from an unrelated failure.

§Code first, then text (0.15.19, review C-20)

libsql::Error::SqliteFailure(1811, msg) is what a guard produces, and msg is the crate’s own abort string verbatim — the probe above prints it, and the “libSQL prefix” this was thought to depend on is Display’s, not the message’s. So two things improve at once. The needle is matched against the engine’s message field rather than against a rendered string, which removes Display as a layer that can change underneath the classification; and a non-trigger error that happens to quote one of these strings — a caller’s own text echoed back in a NOT NULL message, say — can no longer be read as a guard.

The free-text arm stays as the fallback, because not every route to this function produces SqliteFailure: an error wrapped or re-rendered on the way here would otherwise degrade every guard to AbortKind::NotAGuard at once, which is the silent failure this function exists to concentrate rather than to cause.

The needles are the crate::schema::ddl constants spliced into the triggers themselves, so guard and classifier cannot drift.