#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
pub enum ProjTransformErrorKind {
#[display("PROJ creation error: {}", _0)]
Create(String),
#[display("PROJ operation error: {}", _0)]
Operation(String),
}
#[derive(Debug, derive_more::Display, derive_more::Error)]
#[display("Proj error: {} at {}:{}", kind, file, line)]
pub struct ProjTransformError {
pub kind: ProjTransformErrorKind,
pub file: &'static str,
pub line: u32,
}
impl ProjTransformError {
#[track_caller]
pub fn create(msg: impl std::fmt::Display) -> Self {
let loc = std::panic::Location::caller();
Self {
kind: ProjTransformErrorKind::Create(msg.to_string()),
file: loc.file(),
line: loc.line(),
}
}
#[track_caller]
pub fn operation(msg: impl std::fmt::Display) -> Self {
let loc = std::panic::Location::caller();
Self {
kind: ProjTransformErrorKind::Operation(msg.to_string()),
file: loc.file(),
line: loc.line(),
}
}
}
pub type ProjResult<T> = Result<T, ProjTransformError>;