Package net.carcdr.ycrdt
Interface ObserverErrorHandler
- All Known Implementing Classes:
DefaultObserverErrorHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for handling exceptions thrown by observers.
Observer callbacks should not throw exceptions, but if they do, this handler provides a way for applications to intercept and handle those exceptions (e.g., for logging or monitoring).
Example usage:
doc.setObserverErrorHandler((exception, source) -> {
logger.error("Observer error in {}: {}", source, exception.getMessage(), exception);
});
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidhandleError(Exception exception, Object source) Handles an exception thrown by an observer callback.
-
Method Details
-
handleError
Handles an exception thrown by an observer callback.This method is called when an observer throws an exception during event dispatch. The handler should not re-throw the exception, as this could disrupt other observers from receiving the event.
- Parameters:
exception- the exception that was thrownsource- the object that dispatched the event (e.g., YText, YArray, YDoc)
-