Class EmailException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EmailConfigException, EmailReceiveException, EmailSecurityException, EmailSendException, EmailTemplateException

public class EmailException extends OpenException
Email Exception Base Class 邮件异常基类

Base exception class for all email-related errors.

所有邮件相关错误的基类异常。

Features | 主要功能:

  • Error code support - 错误码支持
  • Email context preservation - 邮件上下文保留
  • Retryable flag - 可重试标志

Usage Examples | 使用示例:

try {
    OpenEmail.send(email);
} catch (EmailException e) {
    if (e.isRetryable()) {
        // Schedule for retry
    }
    log.error("Error code: {}", e.getEmailErrorCode().getCode());
}

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
Since:
JDK 25, opencode-base-email V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • EmailException

      public EmailException(String message)
      Create exception with message only 仅使用消息创建异常
      Parameters:
      message - the error message | 错误消息
    • EmailException

      public EmailException(String message, Throwable cause)
      Create exception with message and cause 使用消息和原因创建异常
      Parameters:
      message - the error message | 错误消息
      cause - the cause | 原因
    • EmailException

      public EmailException(String message, EmailErrorCode errorCode)
      Create exception with message and error code 使用消息和错误码创建异常
      Parameters:
      message - the error message | 错误消息
      errorCode - the error code | 错误码
    • EmailException

      public EmailException(String message, Throwable cause, Email email, EmailErrorCode errorCode)
      Create exception with all parameters 使用所有参数创建异常
      Parameters:
      message - the error message | 错误消息
      cause - the cause | 原因
      email - the related email | 相关邮件
      errorCode - the error code | 错误码
  • Method Details

    • getEmailErrorCode

      public EmailErrorCode getEmailErrorCode()
      Get the email error code 获取邮件错误码
      Returns:
      the email error code | 邮件错误码
    • getEmail

      public Email getEmail()
      Get the related email (if available) 获取相关邮件(如果可用)
      Returns:
      the email or null | 邮件或null
    • isRetryable

      public boolean isRetryable()
      Check if error is retryable 检查错误是否可重试
      Returns:
      true if retryable | 可重试返回true