Skip to main content

ComposeError

Enum ComposeError 

Source
pub enum ComposeError {
    XPath {
        source: XPathError,
        expr: String,
    },
    Document(BufferDocumentError),
    Copy {
        source: CopyError,
        at: String,
    },
    Serialize(SerializeError),
    Io(Error),
    UnboundPrefix {
        prefix: String,
        at: String,
    },
    InvalidName(String),
    NotANode,
    NotSingleton {
        len: usize,
    },
    BuildShape {
        top_level: usize,
    },
}
Expand description

Why a composition step failed.

Every variant either wraps an error from the layer that produced it — the XPath engine, the document builder, the subtree copy, the serializer, the file system — or reports a mistake in the composition itself: a prefix nothing binds, a name that is not an XML name, a value of the wrong shape.

From conversions exist for each wrapped error, so ? works throughout a composition body. The two variants that carry context — XPath and Copy — get it filled in by the code that has it: the conversion leaves the expression text and the form path empty, and Composer::eval and the emitter set them.

use xsd_schema::compose::ComposeError;

let err = ComposeError::NotSingleton { len: 3 };
assert!(err.to_string().contains('3'));

Variants§

§

XPath

An expression could not be compiled or evaluated.

expr is the expression text, so a failure names the call site rather than just the error code.

use bumpalo::Bump;
use xsd_schema::compose::{ComposeError, Composer};
use xsd_schema::namespace::NameTable;

let arena = Bump::new();
let names = NameTable::new();
let c = Composer::new(&arena, &names);

// `$missing` was never declared.
match c.eval("$missing", &[], None, Vec::new()) {
    Err(ComposeError::XPath { expr, .. }) => assert_eq!(expr, "$missing"),
    other => panic!("expected a refusal, got {other:?}"),
}

Fields

§source: XPathError

What the engine reported.

§expr: String

The expression text, empty when the error was converted with ? before reaching a call site that knows it.

§

Document(BufferDocumentError)

The document builder refused a node, or a document could not be parsed.

§

Copy

A spliced value could not be copied into the result.

at is the path of the form whose content failed, spelled like an XPath step list — result/item_tuple[3].

Fields

§source: CopyError

What the copy reported.

§at: String

The failing form’s path, empty when the error was converted with ? outside the emitter.

§

Serialize(SerializeError)

The result could not be written as XML.

§

Io(Error)

A file could not be read, or a writer failed.

§

UnboundPrefix

A form used a prefix that neither the form nor the composer binds.

Fields

§prefix: String

The unbound prefix.

§at: String

The path of the form that used it.

§

InvalidName(String)

A literal name is not an XML NCName or prefix:NCName.

§

NotANode

An atomic value turned up where a node was required.

§

NotSingleton

A sequence of several items turned up where one was required.

Fields

§len: usize

How many items there were.

§

BuildShape

Composer::build was given something other than exactly one top-level element.

Use Composer::build_sequence for a result with none, or several.

Fields

§top_level: usize

How many top-level elements the build would produce.

Trait Implementations§

Source§

impl Debug for ComposeError

Source§

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

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

impl Display for ComposeError

Source§

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

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

impl Error for ComposeError

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<BufferDocumentError> for ComposeError

Source§

fn from(source: BufferDocumentError) -> Self

Converts to this type from the input type.
Source§

impl From<CopyError> for ComposeError

Source§

fn from(source: CopyError) -> Self

Wraps a copy error with no form path; the emitter attaches it.

Source§

impl From<Error> for ComposeError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<SerializeError> for ComposeError

Source§

fn from(source: SerializeError) -> Self

Converts to this type from the input type.
Source§

impl From<XPathError> for ComposeError

Source§

fn from(source: XPathError) -> Self

Wraps an engine error with no expression text; the evaluating call site attaches it.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ComposeError

§

impl !UnwindSafe for ComposeError

§

impl Forget for ComposeError

§

impl Freeze for ComposeError
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<RaisedErrorData> is !null: Freeze, PhantomData<ArcInner<RaisedErrorData>>: Freeze, *const () is !null: Freeze, PhantomData<ErrorData<CustomOwner>>: Freeze, *const str is !null: Freeze, PhantomData<str>: Freeze, &'static str: Freeze,

§

impl Move for ComposeError

§

impl Send for ComposeError
where RawVecInner: Send, Arc<RaisedErrorData>: Send, Repr: Send, BoxRaw<str>: Send, &'static str: Send,

§

impl Sync for ComposeError
where RawVecInner: Sync, Arc<RaisedErrorData>: Sync, Repr: Sync, BoxRaw<str>: Sync,

§

impl Unpin for ComposeError
where *const u8 is !null: Unpin, Arc<RaisedErrorData>: Unpin, *const () is !null: Unpin, &'static SimpleMessage: Unpin, *const Custom is !null: Unpin, Box<str>: Unpin, &'static str: Unpin,

§

impl UnsafeUnpin for ComposeError
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<RaisedErrorData> is !null: UnsafeUnpin, PhantomData<ArcInner<RaisedErrorData>>: UnsafeUnpin, *const () is !null: UnsafeUnpin, PhantomData<ErrorData<CustomOwner>>: UnsafeUnpin, *const str is !null: UnsafeUnpin, PhantomData<str>: UnsafeUnpin, &'static str: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.