Skip to main content

atomr_agents_deep_research_shell/
error.rs

1//! Crate error type.
2
3use atomr_agents_core::AgentError;
4use thiserror::Error;
5
6/// Errors raised by the deep-research shell.
7#[derive(Debug, Error)]
8pub enum ShellError {
9    /// Misconfiguration (e.g. no classifier/shallow/deep wired).
10    #[error("configuration error: {0}")]
11    Config(String),
12
13    /// The intent classifier failed.
14    #[error("classifier error: {0}")]
15    Classifier(String),
16
17    /// The shallow-path researcher failed.
18    #[error("shallow path error: {0}")]
19    Shallow(String),
20
21    /// The deep harness returned an error.
22    #[error("deep harness error: {0}")]
23    Deep(String),
24
25    /// Underlying web-search provider failure.
26    #[error("web search error: {0}")]
27    WebSearch(#[from] atomr_agents_web_search_core::WebSearchError),
28
29    /// Serialization / deserialization failure.
30    #[error("serialization error: {0}")]
31    Serde(#[from] serde_json::Error),
32
33    /// Catch-all.
34    #[error("internal error: {0}")]
35    Internal(String),
36}
37
38impl ShellError {
39    pub fn config(msg: impl Into<String>) -> Self {
40        Self::Config(msg.into())
41    }
42    pub fn classifier(msg: impl Into<String>) -> Self {
43        Self::Classifier(msg.into())
44    }
45    pub fn shallow(msg: impl Into<String>) -> Self {
46        Self::Shallow(msg.into())
47    }
48    pub fn deep(msg: impl Into<String>) -> Self {
49        Self::Deep(msg.into())
50    }
51    pub fn internal(msg: impl Into<String>) -> Self {
52        Self::Internal(msg.into())
53    }
54}
55
56impl From<ShellError> for AgentError {
57    fn from(e: ShellError) -> Self {
58        AgentError::Harness(e.to_string())
59    }
60}
61
62/// Crate result alias.
63pub type Result<T, E = ShellError> = std::result::Result<T, E>;