xsd-parser 1.5.2

Rust code generator for XML schema files
Documentation
use thiserror::Error;

use crate::{
    models::{code::InvalidIdentPath, schema::NamespaceId, TypeIdent},
    pipeline::generator::ValueGeneratorMode,
};

/// Error that might be raised by the [`Generator`](super::Generator).
#[derive(Debug, Error)]
pub enum Error {
    /// Unknown type identifier.
    ///
    /// Is raised if a specific identifier could not be resolved to it's
    /// corresponding type information.
    #[error("Unknown type identifier: {0}!")]
    UnknownType(TypeIdent),

    /// Unknown namespace.
    ///
    /// Is raised if a specific namespace id could not be resolved to it's
    /// corresponding namespace information.
    #[error("Unknown namespace: {0:?}!")]
    UnknownNamespace(NamespaceId),

    /// Invalid default value.
    ///
    /// Is raised if the default value for an attribute defined in the schema
    /// could not be converted to a suitable default code snippet.
    #[error("Invalid default value for type (ident={ident:?}, value={value}, mode: {mode:?})!")]
    InvalidDefaultValue {
        /// The identifier of the type for which the value should be generated.
        ident: TypeIdent,

        /// The value that should be generated.
        value: String,

        /// The mode that determines how the value should be generated.
        mode: ValueGeneratorMode,
    },

    /// Invalid identifier.
    ///
    /// Is raised if the user passed a invalid identifier.
    #[error("{0}")]
    InvalidIdentifier(
        #[from]
        #[source]
        InvalidIdentPath,
    ),
}