use crate::verify::VerifyError;
pub type HandlerError = Box<dyn std::error::Error + Send + Sync + 'static>;
pub type HandlerResult<T> = Result<T, HandlerError>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum SlackError {
#[error("slack config: {0}")]
Config(String),
#[error("slack {method} failed: {code}")]
Api {
method: String,
code: String,
needed: Option<String>,
},
#[error("slack rate limited (retry after {retry_after_secs:?} s)")]
RateLimited {
retry_after_secs: Option<u64>,
},
#[error("slack http {status}")]
Http {
status: u16,
body: String,
},
#[error("slack transport: {0}")]
Transport(String),
#[error("slack reply decode: {0}")]
Decode(String),
#[error("response_url is not an allowed Slack URL")]
BadResponseUrl,
#[error(transparent)]
Verify(#[from] VerifyError),
}
impl SlackError {
#[must_use]
pub fn slack_code(&self) -> Option<&str> {
match self {
Self::Api { code, .. } => Some(code),
_ => None,
}
}
}