Skip to main content

proj_core/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5/// Errors produced by CRS resolution, transform construction, and coordinate
6/// conversion.
7///
8/// The enum is `#[non_exhaustive]`: match the variants you handle and keep a
9/// wildcard arm. Message payloads carry human-readable context; structured
10/// variants are added as concrete matching needs appear.
11#[derive(Debug, Error)]
12#[non_exhaustive]
13pub enum Error {
14    #[error("unknown CRS: {0}")]
15    UnknownCrs(String),
16
17    #[error("unsupported projection: {0}")]
18    UnsupportedProjection(String),
19
20    #[error("unknown operation: {0}")]
21    UnknownOperation(String),
22
23    #[error("operation selection failed: {0}")]
24    OperationSelection(String),
25
26    #[error("invalid CRS definition: {0}")]
27    InvalidDefinition(String),
28
29    #[error("coordinate out of range: {0}")]
30    OutOfRange(String),
31
32    /// A fixed-point iteration exhausted its budget without meeting its
33    /// tolerance: the input is outside the domain where the inverse series
34    /// contracts.
35    #[error("{context} did not converge after {iterations} iterations")]
36    NonConvergence {
37        context: &'static str,
38        iterations: usize,
39    },
40
41    #[error(transparent)]
42    Grid(#[from] crate::grid::GridError),
43}