Skip to main content

aria_core/
error.rs

1use std::fmt;
2
3#[derive(Debug, PartialEq)]
4pub enum AriaError {
5    /// No items registered in the engine
6    NoItems,
7    /// All items filtered out (prereqs, already seen, etc.)
8    NoEligibleItems,
9    /// User ID not found
10    UserNotFound(String),
11    /// Item ID not found
12    ItemNotFound(String),
13    /// Prerequisite graph contains a cycle
14    CyclicPrerequisite(String),
15    /// Factor list is empty — engine needs at least one factor
16    NoFactors,
17    /// Serialisation / deserialisation failure
18    SerialisationError(String),
19}
20
21impl fmt::Display for AriaError {
22    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23        match self {
24            AriaError::NoItems => write!(f, "No items registered"),
25            AriaError::NoEligibleItems => write!(f, "No eligible items for this user"),
26            AriaError::UserNotFound(id) => write!(f, "User not found: {id}"),
27            AriaError::ItemNotFound(id) => write!(f, "Item not found: {id}"),
28            AriaError::CyclicPrerequisite(id) => {
29                write!(f, "Cyclic prerequisite detected at item: {id}")
30            }
31            AriaError::NoFactors => write!(f, "Engine has no factors registered"),
32            AriaError::SerialisationError(msg) => write!(f, "Serialisation error: {msg}"),
33        }
34    }
35}
36
37impl std::error::Error for AriaError {}