autoagents_core/agent/
error.rs1use std::fmt::Debug;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
6pub enum RunnableAgentError {
7 #[error("Agent execution failed: {0}")]
9 ExecutorError(String),
10
11 #[error("Task processing failed: {0}")]
13 TaskError(String),
14
15 #[error("Agent not found: {0}")]
17 AgentNotFound(uuid::Uuid),
18
19 #[error("Agent initialization failed: {0}")]
21 InitializationError(String),
22
23 #[error("Failed to send event: {0}")]
25 EventSendError(String),
26
27 #[error("Agent state error: {0}")]
29 StateError(String),
30
31 #[error(transparent)]
33 Other(#[from] Box<dyn std::error::Error + Send + Sync>),
34}
35
36impl RunnableAgentError {
37 pub fn executor_error(error: impl std::error::Error) -> Self {
39 Self::ExecutorError(error.to_string())
40 }
41
42 pub fn task_error(msg: impl Into<String>) -> Self {
44 Self::TaskError(msg.into())
45 }
46
47 pub fn event_send_error(error: impl std::error::Error) -> Self {
49 Self::EventSendError(error.to_string())
50 }
51}
52
53impl<T> From<tokio::sync::mpsc::error::SendError<T>> for RunnableAgentError
55where
56 T: Debug + Send + 'static,
57{
58 fn from(error: tokio::sync::mpsc::error::SendError<T>) -> Self {
59 Self::EventSendError(error.to_string())
60 }
61}
62
63#[derive(Debug, thiserror::Error)]
64pub enum AgentBuildError {
65 #[error("Build Failure")]
66 BuildFailure(String),
67}
68
69#[derive(Error, Debug)]
70pub enum AgentResultError {
71 #[error("No output available in result")]
72 NoOutput,
73
74 #[error("Failed to deserialize executor output: {0}")]
75 DeserializationError(#[from] serde_json::Error),
76
77 #[error("Agent output extraction error: {0}")]
78 AgentOutputError(String),
79}