Class SilentErrorHandler
java.lang.Object
io.fluxzero.sdk.tracking.SilentErrorHandler
- All Implemented Interfaces:
ErrorHandler
An
ErrorHandler implementation that suppresses all processing errors and allows message tracking to
continue.
This handler is ideal for non-critical consumers where message loss or failure should not disrupt the application, such as:
- Metrics collection
- Auditing or logging projections
- Replays for observability/debugging
Logging Behavior:
- If
maxLevelis specified, all errors are logged at that level (e.g.,WARN,DEBUG). - If
maxLevelisnull, 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
Resultmessage but does not halt processing. - The original
retryFunctionis not invoked. - No exceptions are thrown—tracking always continues.
Usage: Can be registered via Consumer.errorHandler() or programmatically via ConsumerConfiguration.
@Consumer(name = "audit", errorHandler = SilentErrorHandler.class)
public class AuditProjection {
@HandleEvent
void on(UserLoggedIn event) {
// Failure to write to audit log won't affect tracking
}
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aSilentErrorHandlerthat does not log any errors. -
Method Summary
Modifier and TypeMethodDescriptionhandleError(Throwable error, String errorMessage, Callable<?> retryFunction) Handles the given error by optionally logging it and then returning it without retry or propagation.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ErrorHandler
handleError
-
Constructor Details
-
SilentErrorHandler
public SilentErrorHandler()Constructs aSilentErrorHandlerthat does not log any errors.
-
-
Method Details
-
handleError
Handles the given error by optionally logging it and then returning it without retry or propagation.- Specified by:
handleErrorin interfaceErrorHandler- Parameters:
error- theThrowableencountered during message processingerrorMessage- context about the failureretryFunction- the operation that was attempted (ignored in this implementation)- Returns:
- the original error object (may be published as a
Resultmessage)
-