Skip to main content

ZuError

Enum ZuError 

Source
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

Fields

§what: &'static str
§detail: String
§

Unsupported

Fields

§what: &'static str
§id: u32
§

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

Source

pub fn gql(status: GqlStatus, detail: impl Into<String>) -> Self

Raises status with our own account of what happened.

Source

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.

Source

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.

Source

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.

Source

pub fn subject(&self) -> Option<&Subject>

What the condition is about, when it is about something named.

Source

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.

Source

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.

Source

pub fn diagnostic(&self) -> Option<&DiagnosticRecord>

The diagnostic record for this error, if it has one.

Source

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.

Source

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 Debug for ZuError

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for ZuError

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Error for ZuError

Source§

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

Replaced by Error::source.
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
Source§

impl From<Error> for ZuError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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.