Something went wrong. Try again.
The smokesignal.events web application forked from smokesignal.events/smokesignal
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186use thiserror::Error;
/// Represents errors that can occur during email operations.////// These errors typically occur during email template rendering,/// email confirmation token generation/verification, and SMTP sending.#[derive(Debug, Error)]pub enum EmailError { /// Error when the HMAC secret key is invalid. /// /// This error occurs when attempting to create an HMAC instance with /// an invalid key format or length. #[error("error-smokesignal-email-1 Invalid HMAC key: {0}")] InvalidHmacKey(String),
/// Error when the confirmation token format is invalid. /// /// This error occurs when attempting to parse a confirmation token /// that doesn't match the expected format (token.time_bucket.signature). #[error("error-smokesignal-email-2 Invalid confirmation token format")] InvalidTokenFormat,
/// Error when the time bucket in a confirmation token cannot be parsed. /// /// This error occurs when the time bucket component of a confirmation /// token is not a valid integer. #[error("error-smokesignal-email-3 Invalid time bucket in confirmation token")] InvalidTimeBucket,
/// Error when the confirmation token signature is invalid or expired. /// /// This error occurs when the HMAC signature of a confirmation token /// doesn't match the expected value, or the token has expired (older /// than the previous 10-minute time bucket). #[error("error-smokesignal-email-4 Invalid or expired confirmation token signature")] InvalidOrExpiredSignature,
/// Error when a template file contains invalid UTF-8. /// /// This error occurs when loading an email template file that contains /// invalid UTF-8 byte sequences. #[error("error-smokesignal-email-5 Invalid UTF-8 in template {template}: {details}")] InvalidUtf8InTemplate { /// The name of the template file. template: String, /// Details about the UTF-8 error. details: String, },
/// Error when adding a template to the template engine fails. /// /// This error occurs when the template engine rejects a template, /// typically due to syntax errors or invalid template directives. #[error("error-smokesignal-email-6 Failed to add template {template}: {details}")] TemplateAddFailed { /// The name of the template file. template: String, /// Details about why adding the template failed. details: String, },
/// Error when retrieving a text template fails. /// /// This error occurs when attempting to get a template that doesn't /// exist or cannot be loaded from the template engine. #[error("error-smokesignal-email-7 Failed to get text template {template}: {details}")] TextTemplateGetFailed { /// The path to the template. template: String, /// Details about the retrieval failure. details: String, },
/// Error when rendering a text template fails. /// /// This error occurs when template rendering fails, typically due to /// missing variables or invalid template syntax. #[error("error-smokesignal-email-8 Failed to render text template {template}: {details}")] TextTemplateRenderFailed { /// The path to the template. template: String, /// Details about the rendering failure. details: String, },
/// Error when retrieving an HTML template fails. /// /// This error occurs when attempting to get an HTML template that doesn't /// exist or cannot be loaded from the template engine. #[error("error-smokesignal-email-9 Failed to get HTML template {template}: {details}")] HtmlTemplateGetFailed { /// The path to the template. template: String, /// Details about the retrieval failure. details: String, },
/// Error when rendering an HTML template fails. /// /// This error occurs when HTML template rendering fails, typically due to /// missing variables or invalid template syntax. #[error("error-smokesignal-email-10 Failed to render HTML template {template}: {details}")] HtmlTemplateRenderFailed { /// The path to the template. template: String, /// Details about the rendering failure. details: String, },
/// Error when CSS inlining fails. /// /// This error occurs when the CSS inlining process fails, typically /// due to invalid CSS syntax or malformed HTML. #[error("error-smokesignal-email-11 Failed to inline CSS in template {template}: {details}")] CssInlineFailed { /// The path to the template. template: String, /// Details about the CSS inlining failure. details: String, },
/// Error when HTML minification fails. /// /// This error occurs when the HTML minification process fails, /// typically due to malformed HTML structure. #[error("error-smokesignal-email-12 Failed to minify HTML in template {template}: {details}")] HtmlMinifyFailed { /// The path to the template. template: String, /// Details about the minification failure. details: String, },
/// Error when parsing SMTP credentials fails. /// /// This error occurs when the SMTP username cannot be parsed into /// valid SMTP credentials format. #[error("error-smokesignal-email-13 Failed to parse SMTP credentials: {0}")] SmtpCredentialsParseFailed(String),
/// Error when the "from" email address is invalid. /// /// This error occurs when the SMTP_FROM address cannot be parsed /// as a valid email address. #[error("error-smokesignal-email-14 Invalid from email address: {0}")] InvalidFromAddress(String),
/// Error when a recipient email address is invalid. /// /// This error occurs when a recipient's email address cannot be parsed /// as a valid email address. #[error("error-smokesignal-email-15 Invalid recipient email address {address}: {details}")] InvalidRecipientAddress { /// The invalid email address. address: String, /// Details about why the address is invalid. details: String, },
/// Error when building an email message fails. /// /// This error occurs when the email builder fails to construct a valid /// email message, typically due to missing required fields. #[error("error-smokesignal-email-16 Failed to build email message: {0}")] EmailBuildFailed(String),
/// Error when sending an email fails. /// /// This error occurs when the SMTP transport fails to send the email, /// typically due to network issues or SMTP server errors. #[error("error-smokesignal-email-17 Failed to send email: {0}")] EmailSendFailed(String),
/// Error when an attachment content type is invalid. /// /// This error occurs when parsing a content type string for an email /// attachment fails. #[error("error-smokesignal-email-18 Invalid attachment content type {content_type}: {details}")] InvalidAttachmentContentType { /// The invalid content type string. content_type: String, /// Details about the parsing failure. details: String, },}