Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Is it possible to use try in an exception handler? #300

Open
torsten-liermann opened this issue Jul 17, 2018 · 1 comment
Open

Q: Is it possible to use try in an exception handler? #300

torsten-liermann opened this issue Jul 17, 2018 · 1 comment

Comments

@torsten-liermann
Copy link

torsten-liermann commented Jul 17, 2018

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.

@johnmcclean
Copy link
Member

johnmcclean commented Jul 17, 2018

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, ...)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants