Class EventException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EventListenerException, EventPublishException, EventSecurityException, EventStoreException

public class EventException extends OpenException
Event Exception Base Class 事件异常基类

Base exception class for all event-related errors, extending OpenException to participate in the unified OpenCode exception hierarchy.

所有事件相关错误的基类异常,继承 OpenException 以参与 OpenCode 统一异常体系。

Features | 主要功能:

  • Error code support (EventErrorCode) - 错误码支持
  • Event context preservation - 事件上下文保留
  • Inherits OpenException component/errorCode formatting - 继承 OpenException 组件/错误码格式

Usage Examples | 使用示例:

try {
    OpenEvent.getDefault().publish(event);
} catch (EventException e) {
    log.error("Event error: code={}, message={}",
        e.getEventErrorCode().getCode(), e.getMessage());
}

Security | 安全性:

  • Thread-safe: No - 线程安全: 否
Since:
JDK 25, opencode-base-event V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • EventException

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

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

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

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

    • getEventErrorCode

      public EventErrorCode getEventErrorCode()
      Get the event error code 获取事件错误码
      Returns:
      the event error code | 事件错误码
    • getEvent

      public Event getEvent()
      Get the related event (if available) 获取相关事件(如果可用)
      Returns:
      the event or null | 事件或null