use capsula_core::error::CapsulaError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum SlackNotifyError {
#[error("HTTP request to Slack API failed: {0}")]
HttpRequest(#[from] reqwest::Error),
#[error("Slack API returned an error: {message}")]
SlackApi { message: String },
#[error("Failed to serialize Slack notify hook: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Slack token not provided in config and SLACK_BOT_TOKEN environment variable not set")]
MissingToken,
#[error("Invalid glob pattern '{pattern}': {source}")]
GlobPattern {
pattern: String,
source: glob::PatternError,
},
#[error("Failed to read attachment file '{path}': {source}")]
FileIo {
path: String,
source: std::io::Error,
},
}
impl From<SlackNotifyError> for CapsulaError {
fn from(err: SlackNotifyError) -> Self {
Self::HookFailed {
hook: "notify-slack".to_string(),
source: Box::new(err),
}
}
}