feat(memory): 添加记忆系统模块
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//! 记忆系统错误类型。
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// 记忆系统错误枚举。
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MemoryError {
|
||||
#[error("Item not found: {0}")]
|
||||
NotFound(String),
|
||||
|
||||
#[error("Storage error: {0}")]
|
||||
Storage(String),
|
||||
|
||||
#[error("Serialization error: {0}")]
|
||||
Serialization(String),
|
||||
|
||||
#[error("Invalid input: {0}")]
|
||||
InvalidInput(String),
|
||||
|
||||
#[error("Retrieval error: {0}")]
|
||||
RetrievalError(String),
|
||||
}
|
||||
|
||||
impl MemoryError {
|
||||
/// 是否为可恢复错误(调用方可重试或调整参数)。
|
||||
pub fn is_recoverable(&self) -> bool {
|
||||
matches!(self, Self::NotFound(_) | Self::RetrievalError(_))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user