xsd_parser/pipeline/renderer/
error.rs

1use thiserror::Error;
2
3use crate::models::{code::InvalidIdentPath, schema::NamespaceId, Ident};
4
5/// Error that might be raised by the [`Generator`](crate::Generator).
6#[derive(Debug, Error)]
7pub enum Error {
8    /// Unknown type identifier.
9    ///
10    /// Is raised if a specific identifier could not be resolved to it's
11    /// corresponding type information.
12    #[error("Unknown type identifier: {0}!")]
13    UnknownType(Ident),
14
15    /// Unknown namespace.
16    ///
17    /// Is raised if a specific namespace id could not be resolved to it's
18    /// corresponding namespace information.
19    #[error("Unknown namespace: {0:?}!")]
20    UnknownNamespace(NamespaceId),
21
22    /// Invalid default value.
23    ///
24    /// Is raised if the default value for an attribute defined in the schema
25    /// could not be converted to a suitable default code snippet.
26    #[error("Invalid default value for type {0:?}: {1}!")]
27    InvalidDefaultValue(Ident, String),
28
29    /// Invalid identifier.
30    ///
31    /// Is raised if the user passed a invalid identifier.
32    #[error("{0}")]
33    InvalidIdentifier(
34        #[from]
35        #[source]
36        InvalidIdentPath,
37    ),
38}