Skip to main content

mojxml_parser/
error.rs

1// use proj::ProjCreateError;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("XML stream parsing error: {0}")]
6    XmlStream(#[from] quick_xml::Error),
7    #[error("Encoding error: {0}")]
8    Encoding(#[from] std::str::Utf8Error),
9    #[error("Missing required element: {0}")]
10    MissingElement(String),
11    #[error("Unsupported CRS: {0}")]
12    UnsupportedCrs(String),
13    #[error("Missing attribute '{attribute}' on element '{element}'")]
14    MissingAttribute { element: String, attribute: String },
15    #[error("Failed to parse float: {0}")]
16    ParseFloat(#[from] std::num::ParseFloatError),
17    #[error("Failed to find point referenced by ID: {0}")]
18    PointNotFound(String),
19    #[error("Unexpected XML element: {0}")]
20    UnexpectedElement(String),
21    #[error("Projection error: {0}")]
22    Projection(#[from] proj4rs::errors::Error),
23    #[error("IO error: {0}")]
24    FS(#[from] std::io::Error),
25    #[error("Failed to calculate interior point")]
26    InteriorPointUnavailable,
27}
28
29pub type Result<T> = std::result::Result<T, Error>;