Class ErrorReportingInterceptor

java.lang.Object
io.fluxzero.sdk.tracking.handling.errorreporting.ErrorReportingInterceptor
All Implemented Interfaces:
HandlerDecorator, HandlerInterceptor

public class ErrorReportingInterceptor extends Object implements HandlerInterceptor
HandlerInterceptor that reports exceptions to the configured ErrorGateway.

This interceptor captures any uncaught exceptions thrown during message handling and appends them to the error log. It also supports reporting errors from asynchronous CompletionStage results returned by handler methods.

Local handler invocations (typically in-process invocations marked as @LocalHandler) are excluded from error reporting.

Behavior

  • If the handler returns a CompletionStage, any exception occurring during its completion is reported.
  • If the handler throws an exception synchronously, it is reported immediately and rethrown.
  • Exceptions marked as FunctionalException or TechnicalException are passed through as-is.
  • Other exceptions are wrapped in a TechnicalException and enriched with stack trace metadata.
See Also:
  • Constructor Details

    • ErrorReportingInterceptor

      public ErrorReportingInterceptor()
  • Method Details

    • wrap

      public io.fluxzero.common.handling.Handler<DeserializingMessage> wrap(io.fluxzero.common.handling.Handler<DeserializingMessage> handler)
      Description copied from interface: HandlerInterceptor
      Wraps a Handler with this interceptor, producing an intercepted handler.
      Specified by:
      wrap in interface HandlerDecorator
      Specified by:
      wrap in interface HandlerInterceptor
      Parameters:
      handler - the original handler to wrap
      Returns:
      an intercepted handler that applies this interceptor to all handled messages
    • interceptHandling

      public Function<DeserializingMessage, Object> interceptHandling(Function<DeserializingMessage, Object> function, io.fluxzero.common.handling.HandlerInvoker invoker)
      Description copied from interface: HandlerInterceptor
      Intercepts the message handling logic.

      The function parameter represents the next step in the handling chain— typically the actual message handler. The invoker provides metadata and invocation logic for the underlying handler method.

      Within this method, an interceptor may:

      • Modify the DeserializingMessage before passing it to the handler
      • Bypass the handler entirely and return a value directly
      • Wrap the result after the handler is invoked

      Note: Interceptors may return a different DeserializingMessage, but it must be compatible with a handler method in the same target class. If no suitable handler is found, an exception will be thrown.

      Specified by:
      interceptHandling in interface HandlerInterceptor
      Parameters:
      function - the next step in the handler chain (typically the handler itself)
      invoker - the metadata and execution strategy for the actual handler method
      Returns:
      a decorated function that wraps handling behavior
    • reportError

      protected void reportError(Throwable e, io.fluxzero.common.handling.HandlerDescriptor invoker, DeserializingMessage cause)