Skip to main content

soma_provider_adapters/
error.rs

1//! Re-exports of the generic provider error type plus adapter-local error
2//! types shared across sidecar-executing adapters (ai-sdk, python).
3
4pub use soma_provider_core::{redact_public, ProviderError};
5
6/// A bounded sidecar child process failed for a reason short of an
7/// application-level `ProviderError` — surfaced by [`crate::sidecar`] and
8/// converted to a `ProviderError` at each adapter's call boundary.
9#[cfg(feature = "sidecar")]
10#[derive(Debug)]
11pub enum SidecarError {
12    Io(std::io::Error),
13    Join(tokio::task::JoinError),
14    Timeout,
15}
16
17#[cfg(feature = "sidecar")]
18impl std::fmt::Display for SidecarError {
19    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20        match self {
21            Self::Io(error) => write!(f, "{error}"),
22            Self::Join(error) => write!(f, "{error}"),
23            Self::Timeout => write!(f, "sidecar process timed out"),
24        }
25    }
26}
27
28#[cfg(feature = "sidecar")]
29impl std::error::Error for SidecarError {}