autumn_plugin_slack/
error.rs1use crate::verify::VerifyError;
4
5pub type HandlerError = Box<dyn std::error::Error + Send + Sync + 'static>;
7
8pub type HandlerResult<T> = Result<T, HandlerError>;
10
11#[derive(Debug, thiserror::Error)]
13#[non_exhaustive]
14pub enum SlackError {
15 #[error("slack config: {0}")]
17 Config(String),
18 #[error("slack {method} failed: {code}")]
20 Api {
21 method: String,
23 code: String,
25 needed: Option<String>,
27 },
28 #[error("slack rate limited (retry after {retry_after_secs:?} s)")]
30 RateLimited {
31 retry_after_secs: Option<u64>,
33 },
34 #[error("slack http {status}")]
36 Http {
37 status: u16,
39 body: String,
41 },
42 #[error("slack transport: {0}")]
44 Transport(String),
45 #[error("slack reply decode: {0}")]
47 Decode(String),
48 #[error("response_url is not an allowed Slack URL")]
50 BadResponseUrl,
51 #[error(transparent)]
53 Verify(#[from] VerifyError),
54}
55
56impl SlackError {
57 #[must_use]
59 pub fn slack_code(&self) -> Option<&str> {
60 match self {
61 Self::Api { code, .. } => Some(code),
62 _ => None,
63 }
64 }
65}