Files
Genarrative/server-rs/crates/module-editor-agent/src/errors.rs
T
k88936 2fa05cd605 统一画布代理文本与附件输入约束
要求用户消息包含非空文本,附件仅作为消息上下文。
同步后端领域校验、接口错误和请求测试。
禁用前端纯附件发送并更新交互回归测试。
保留发送失败时的草稿与附件恢复行为。
2026-07-31 11:30:48 +08:00

34 lines
1.2 KiB
Rust

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 {}