pub enum ZuError {
Gql(Box<DiagnosticRecord>),
Io(Error),
Corrupt {
what: &'static str,
detail: String,
},
Unsupported {
what: &'static str,
id: u32,
},
InvalidArgument(String),
Conflict(String),
Interrupted,
}Expand description
Top-level error for all zu operations.
Variants§
Gql(Box<DiagnosticRecord>)
A GQL condition, with the standard’s code and our own detail.
Io(Error)
Corrupt
Unsupported
InvalidArgument(String)
Conflict(String)
A compare-and-swap or ownership check lost to a concurrent writer.
Interrupted
The caller asked the statement to stop and it did, at the next
boundary the executor checks (crate::Interrupt). No condition
code, because the standard has none for this and the statement
did not fail: it was stopped, which is a fact about the caller
rather than about the query.
Implementations§
Source§impl ZuError
impl ZuError
Sourcepub fn gql(status: GqlStatus, detail: impl Into<String>) -> Self
pub fn gql(status: GqlStatus, detail: impl Into<String>) -> Self
Raises status with our own account of what happened.
Sourcepub fn gql_at(
status: GqlStatus,
position: Position,
detail: impl Display,
) -> Self
pub fn gql_at( status: GqlStatus, position: Position, detail: impl Display, ) -> Self
The same, raised at a place in the statement text. The message reads as it did before, with the line and column ahead of the detail, and the pair is also kept as a pair so that a caller can point at the token instead of parsing the sentence.
Sourcepub fn gql_in(
status: GqlStatus,
source: &str,
offset: usize,
detail: impl Display,
) -> Self
pub fn gql_in( status: GqlStatus, source: &str, offset: usize, detail: impl Display, ) -> Self
The same, raised at a byte offset into the statement text.
The front end raises through this one rather than through
Self::gql_at, because the source is what turns an offset
into a line and a column and it is also the only way to quote
the line back. A caller three layers up has the message and the
numbers and no longer has the text.
Sourcepub fn about(self, subject: Subject) -> Self
pub fn about(self, subject: Subject) -> Self
The same error, about a thing the statement named.
A builder rather than a fourth constructor, so that a raise site adds a subject without changing which of the three it went through. It does nothing to an engine-internal failure, which has no record to put a subject on.
Sourcepub fn subject(&self) -> Option<&Subject>
pub fn subject(&self) -> Option<&Subject>
What the condition is about, when it is about something named.
Sourcepub fn position(&self) -> Option<Position>
pub fn position(&self) -> Option<Position>
Where in the statement this was raised, when it was raised
somewhere. An engine-internal failure and a runtime condition
both answer None.
Sourcepub fn gqlstatus(&self) -> Option<GqlStatus>
pub fn gqlstatus(&self) -> Option<GqlStatus>
The GQLSTATUS value for this error, if it has one. Engine-internal
errors return None rather than a code that would be a guess.
Sourcepub fn diagnostic(&self) -> Option<&DiagnosticRecord>
pub fn diagnostic(&self) -> Option<&DiagnosticRecord>
The diagnostic record for this error, if it has one.
Sourcepub fn excerpt(&self) -> Option<&str>
pub fn excerpt(&self) -> Option<&str>
The line of the statement this was raised on, when the statement text was in hand where it was raised.
Sourcepub fn retryable(&self) -> bool
pub fn retryable(&self) -> bool
Whether running the same thing again could succeed, which is the one question a caller writing a retry loop is asking.
A lost compare-and-swap is the case: a concurrent writer got
there first, so the work was not applied and the same call on a
fresh read may well win. A condition answers for itself, which
is 40000 transaction rollback and nothing else. Everything
remaining is false, including an interruption, which is not the
engine failing but the caller having asked it to stop.
Trait Implementations§
Source§impl Error for ZuError
impl Error for ZuError
Source§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()