cyclops-integration
cyclops-integration copied to clipboard
Q: Is it possible to use try in an exception handler?
Hi,
I feel like drunk when I see the forest from lambda expressions ...
Is it possible to use Try in an exception handler? The exception handler is a technical construct that treats a given exception differently depending on the exception type. For example:
void globalIntegrationExceptionHandler(Throwable e) {
...
Try.withException(e)
.onFail(Exception1.class, ...)
.onFail(Exception2.class, ...)
Thanks for a hint.
Hey @torsten-liermann ,
It should be possible to use Try in this way.
With later cyclops versions :
void globalIntegrationExceptionHandler(Throwable e) {
Try.failure(e)
.onFail(Exception1.class, ...)
.onFail(Exception2.class, ...)
}
With earlier cyclops versions (e.g. for standalone cyclops-try) :
void globalIntegrationExceptionHandler(Throwable e) {
Failure.of(e)
.onFail(Exception1.class, ...)
.onFail(Exception2.class, ...)
}