Skip to main content

cm_email_webhook_verification/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, WebhookVerificationError>;
4
5#[derive(Debug, Error)]
6pub enum WebhookVerificationError {
7    #[error("Missing required header(s): {0}")]
8    MissingHeaders(String),
9
10    #[error("Invalid signature")]
11    InvalidSignature,
12
13    #[error("Invalid timestamp format")]
14    InvalidTimestamp,
15
16    #[error("Webhook timestamp is outside the allowed tolerance window")]
17    TimestampExpired,
18
19    #[error("Failed to deserialize payload: {0}")]
20    DeserializationError(#[from] serde_json::Error),
21
22    #[error("Failed to decode signature: {0}")]
23    Base64DecodeError(#[from] base64::DecodeError),
24}