irox_carto/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: MIT
// Copyright 2025 IROX Contributors
//

//!
//! Error Types

extern crate alloc;
use alloc::string::String;
use core::error::Error;
use core::fmt::{Display, Formatter};

use irox_enums::EnumName;

#[derive(Debug, Clone, EnumName)]
pub enum ConvertError {
    MissingValue(String),
    MissingProjection(String),
    MismatchedReferenceFrame(String),
}

impl ConvertError {
    pub fn error(&self) -> &str {
        match self {
            ConvertError::MissingValue(e) => e,
            ConvertError::MissingProjection(a) => a,
            ConvertError::MismatchedReferenceFrame(r) => r,
        }
    }
}

impl Display for ConvertError {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.write_fmt(format_args!(
            "ConvertError({}): {}",
            self.name(),
            self.error()
        ))
    }
}

impl Error for ConvertError {}

#[derive(Debug, Clone)]
pub enum ParseError {
    Error,
}