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: XPathErrorWhat the engine reported.
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
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.
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.
BuildShape
Composer::build was given
something other than exactly one top-level element.
Use Composer::build_sequence
for a result with none, or several.
Trait Implementations§
Source§impl Debug for ComposeError
impl Debug for ComposeError
Source§impl Display for ComposeError
impl Display for ComposeError
Source§impl Error for ComposeError
impl Error for ComposeError
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()
Source§impl From<BufferDocumentError> for ComposeError
impl From<BufferDocumentError> for ComposeError
Source§fn from(source: BufferDocumentError) -> Self
fn from(source: BufferDocumentError) -> Self
Source§impl From<CopyError> for ComposeError
impl From<CopyError> for ComposeError
Source§impl From<Error> for ComposeError
impl From<Error> for ComposeError
Source§impl From<SerializeError> for ComposeError
impl From<SerializeError> for ComposeError
Source§fn from(source: SerializeError) -> Self
fn from(source: SerializeError) -> Self
Source§impl From<XPathError> for ComposeError
impl From<XPathError> for ComposeError
Source§fn from(source: XPathError) -> Self
fn from(source: XPathError) -> Self
Wraps an engine error with no expression text; the evaluating call site attaches it.