1use crate::{ast_core::Span, name::XmlName, value_template};
2
3#[derive(Debug, PartialEq)]
4#[cfg_attr(feature = "serde", derive(serde::Serialize))]
5pub enum AttributeError {
6 NotFound { name: XmlName, span: Span },
8 Unexpected { name: XmlName, span: Span },
10 Invalid { value: String, span: Span },
12 InvalidEqName { value: String, span: Span },
14 XPathParser(xee_xpath_ast::ParserError),
16 ValueTemplate(value_template::Error),
18 Internal,
20}
21
22impl From<xee_xpath_ast::ParserError> for AttributeError {
23 fn from(e: xee_xpath_ast::ParserError) -> Self {
24 AttributeError::XPathParser(e)
25 }
26}
27
28impl From<value_template::Error> for AttributeError {
29 fn from(e: value_template::Error) -> Self {
30 AttributeError::ValueTemplate(e)
31 }
32}
33
34#[derive(Debug, PartialEq)]
35#[cfg_attr(feature = "serde", derive(serde::Serialize))]
36pub enum ElementError {
37 Unexpected { span: Span },
39 UnexpectedEnd,
41 Attribute(AttributeError),
43 ValueTemplate(value_template::Error),
44 XPathRunTime(xee_xpath_compiler::error::SpannedError),
46 Internal,
48 Unsupported,
50}
51
52impl From<AttributeError> for ElementError {
53 fn from(error: AttributeError) -> Self {
54 Self::Attribute(error)
55 }
56}
57
58impl From<xee_xpath_compiler::error::SpannedError> for ElementError {
59 fn from(e: xee_xpath_compiler::error::SpannedError) -> Self {
60 ElementError::XPathRunTime(e)
61 }
62}
63
64impl From<value_template::Error> for ElementError {
65 fn from(e: value_template::Error) -> Self {
66 ElementError::ValueTemplate(e)
67 }
68}
69
70impl From<xot::Error> for ElementError {
71 fn from(_e: xot::Error) -> Self {
72 ElementError::Internal
73 }
74}