Skip to main content

vv_agent/memory/
errors.rs

1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct CompactionExhaustedError {
6    pub attempts: u32,
7    pub last_error: Option<String>,
8}
9
10impl CompactionExhaustedError {
11    pub fn new(attempts: u32, last_error: impl Into<Option<String>>) -> Self {
12        Self {
13            attempts,
14            last_error: last_error.into(),
15        }
16    }
17}
18
19impl fmt::Display for CompactionExhaustedError {
20    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
21        write!(
22            formatter,
23            "Context compaction failed after {} consecutive attempts. Last error: {}",
24            self.attempts,
25            self.last_error.as_deref().unwrap_or("None")
26        )
27    }
28}
29
30impl Error for CompactionExhaustedError {}