ogc_cql2/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2
3#![warn(missing_docs)]
4
5//! Errors raised from this library.
6//!
7
8use peg::{error::ParseError, str::LineCol};
9use std::borrow::Cow;
10use thiserror::Error;
11
12/// Variants of error raised from this library.
13#[derive(Debug, Error)]
14pub enum MyError {
15    /// Input/Output realted error.
16    #[error("I/O error: {0}")]
17    IO(#[from] std::io::Error),
18
19    /// Date, time + timestamp (`jiff`) parsing error.
20    #[error("Date-Time error: {0}")]
21    Time(#[from] jiff::Error),
22
23    /// Text-encoding (`peg`) related error.
24    #[error("PEG error: {0:?}")]
25    Text(ParseError<LineCol>),
26
27    /// JSON-encoding (`serde`) related error
28    #[error("Json [Try]From error: {0}")]
29    Json(#[from] serde_json::Error),
30
31    /// Geometry (`geos`) related error.
32    #[error("Geos error: {0}")]
33    Geos(#[from] geos::Error),
34
35    /// Coordinate conversion results in loss of precision.
36    #[error("Converting {0} to `f64` will result in loss of precision")]
37    PrecisionLoss(Cow<'static, str>),
38
39    /// CRS construction error.
40    #[error("CRS creation error: {0}")]
41    CRS(#[from] proj::ProjCreateError),
42
43    /// Coordinate transformation (`proj`) related error.
44    #[error("Proj error: {0}")]
45    Proj(#[from] proj::ProjError),
46
47    /// Runtime error.
48    #[error("Runtime error: {0}")]
49    Runtime(Cow<'static, str>),
50}