use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum SinkError {
#[error("failed to build HTTP client: {0}")]
ClientBuild(String),
#[error("failed to send auth request: {0}")]
AuthRequest(String),
#[error("auth endpoint error: {0}")]
AuthEndpoint(String),
#[error("failed to parse token response: {0}")]
TokenParse(String),
#[error("failed to send data to sink: {message}")]
SendRequest { message: String, retryable: bool },
#[error("sink authentication failed")]
Unauthorized,
#[error("sink rejected data format: {message}")]
UnprocessableEntity { message: String },
#[error("sink returned HTTP {status}: {message}")]
HttpStatus {
status: u16,
message: String,
retryable: bool,
},
#[error("sink shutdown in progress")]
Shutdown,
}
impl SinkError {
pub const fn is_transient(&self) -> bool {
match self {
Self::SendRequest { retryable, .. }
| Self::HttpStatus { retryable, .. } => *retryable,
Self::ClientBuild(_)
| Self::AuthRequest(_)
| Self::AuthEndpoint(_)
| Self::TokenParse(_)
| Self::Unauthorized
| Self::UnprocessableEntity { .. }
| Self::Shutdown => false,
}
}
}