Enum Class EventErrorPolicy

java.lang.Object
java.lang.Enum<EventErrorPolicy>
com.github.copilot.sdk.EventErrorPolicy
All Implemented Interfaces:
Serializable, Comparable<EventErrorPolicy>, Constable

public enum EventErrorPolicy extends Enum<EventErrorPolicy>
Controls how event dispatch behaves when an event handler throws an exception.

This policy is set via CopilotSession.setEventErrorPolicy(EventErrorPolicy) and determines whether remaining event listeners continue to execute after a preceding listener throws an exception. Errors are always logged at Level.WARNING regardless of the policy.

The configured EventErrorHandler (if any) is always invoked regardless of the policy — the policy only controls whether dispatch continues after the error has been logged and the error handler has been called.

The naming follows the convention used by Spring Framework's TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER and TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER.

Example:


 // Default: propagate errors (stop dispatch on first error, log the error)
 session.setEventErrorPolicy(EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS);

 // Opt-in to suppress errors (continue dispatching, log each error)
 session.setEventErrorPolicy(EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS);
 
Since:
1.0.8
See Also:
  • Enum Constant Details

    • SUPPRESS_AND_LOG_ERRORS

      public static final EventErrorPolicy SUPPRESS_AND_LOG_ERRORS
      Suppress errors: log the error and continue dispatching to remaining listeners.

      When a handler throws an exception, the error is logged at Level.WARNING and remaining handlers still execute. The configured EventErrorHandler is called for each error. This is analogous to Spring's LOG_AND_SUPPRESS_ERROR_HANDLER behavior.

    • PROPAGATE_AND_LOG_ERRORS

      public static final EventErrorPolicy PROPAGATE_AND_LOG_ERRORS
      Propagate errors: log the error and stop dispatch on first listener error (default).

      When a handler throws an exception, the error is logged at Level.WARNING and no further handlers are invoked. The configured EventErrorHandler is still called before dispatch stops. This is analogous to Spring's LOG_AND_PROPAGATE_ERROR_HANDLER behavior.

  • Method Details

    • values

      public static EventErrorPolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EventErrorPolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null