Skip to main content

braintrust_sdk_rust/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum BraintrustError {
5    #[error("invalid configuration: {0}")]
6    InvalidConfig(String),
7    #[error("http error: {0}")]
8    Http(#[from] reqwest::Error),
9    #[error("network error: {0}")]
10    Network(String),
11    #[error("API error ({status}): {message}")]
12    Api { status: u16, message: String },
13    #[error("internal channel closed")]
14    ChannelClosed,
15    #[error("background task failed: {0}")]
16    Background(String),
17    #[error("stream aggregation error: {0}")]
18    StreamAggregation(String),
19}
20
21pub type Result<T> = std::result::Result<T, BraintrustError>;