Class SilentErrorHandler

java.lang.Object
io.fluxzero.sdk.tracking.SilentErrorHandler
All Implemented Interfaces:
ErrorHandler

public class SilentErrorHandler extends Object implements ErrorHandler
An ErrorHandler implementation that suppresses all processing errors and allows message tracking to continue.

Start with LoggingErrorHandler so failures remain visible. Use this handler only for deliberately best-effort consumers with separate observability, where skipping a failed effect is acceptable, such as:

  • Metrics collection
  • Optional diagnostic projections
  • Replays for observability/debugging

Logging Behavior:

  • If maxLevel is specified, all errors are logged at that level (e.g., WARN, DEBUG).
  • If maxLevel is null, errors are completely silent—nothing is logged.
  • All logs include the error context and exception stack trace (if any).

Control Flow:

  • The error is returned as-is, meaning it may be published as a Result message but does not halt processing.
  • The original retryFunction is not invoked.
  • No exceptions are thrown—tracking always continues.

Usage: Can be registered via Consumer.errorHandler() or programmatically via ConsumerConfiguration.

@Consumer(name = "diagnostics", errorHandler = SilentErrorHandler.class)
public class DiagnosticProjection {
    @HandleEvent
    void on(UserLoggedIn event) {
        // An optional diagnostic write may be skipped on failure
    }
}
See Also:
  • Constructor Details

    • SilentErrorHandler

      public SilentErrorHandler()
      Constructs a SilentErrorHandler that does not log any errors.
  • Method Details

    • handleError

      public Object handleError(Throwable error, String errorMessage, Callable<?> retryFunction)
      Handles the given error by optionally logging it and then returning it without retry or propagation.
      Specified by:
      handleError in interface ErrorHandler
      Parameters:
      error - the Throwable encountered during message processing
      errorMessage - context about the failure
      retryFunction - the operation that was attempted (ignored in this implementation)
      Returns:
      the original error object (may be published as a Result message)