Skip to main content

kaizen/interchange/atif/
error.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3use std::error::Error;
4use std::fmt::{Display, Formatter};
5
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum AtifImportError {
8    UnsupportedFormat(String),
9    UnsupportedVersion(u16),
10    SessionMismatch {
11        event_id: String,
12        session_id: String,
13    },
14}
15
16impl Display for AtifImportError {
17    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
18        match self {
19            Self::UnsupportedFormat(v) => write!(f, "unsupported ATIF format: {v}"),
20            Self::UnsupportedVersion(v) => write!(f, "unsupported ATIF version: {v}"),
21            Self::SessionMismatch {
22                event_id,
23                session_id,
24            } => {
25                write!(
26                    f,
27                    "event {event_id} does not belong to session {session_id}"
28                )
29            }
30        }
31    }
32}
33
34impl Error for AtifImportError {}