use std::{error::Error, fmt}; #[derive(Clone, Debug, PartialEq, Eq)] pub enum EditorAgentError { MissingConversationId, MissingProjectId, MissingOwnerUserId, MissingMessageId, EmptyMessage, TooManyAttachments, InvalidAttachmentReference, ConversationDeleted, NotConversationOwner, } impl fmt::Display for EditorAgentError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let message = match self { Self::MissingConversationId => "editor agent conversation_id 缺失", Self::MissingProjectId => "editor agent project_id 缺失", Self::MissingOwnerUserId => "editor agent owner_user_id 缺失", Self::MissingMessageId => "editor agent message_id 缺失", Self::EmptyMessage => "消息文本不能为空", Self::TooManyAttachments => "单条消息附件超过上限", Self::InvalidAttachmentReference => "附件引用缺少资源标识", Self::ConversationDeleted => "会话已删除", Self::NotConversationOwner => "当前用户不是会话拥有者", }; write!(f, "{message}") } } impl Error for EditorAgentError {}