I am new to the functional style of programming using vavr.
I have a method returns the data when its executed successfully and if it fails, it returns the MyCustomRunTimeException.
In my Service class, I am calling this API method, when API method fails I have to catch the exception and going to clear my application cache and return the same exception to the caller (another service method in my case).
if method call success I have to return the actual object, not the Try wrapped object.
How can I achieve this using vavr Try?
I tried to use different methods in vavr Try.recover but I am unable to throw the same exception.
Any sample example or snippet could be very helpful for me if some can provide.
Thanks in advance.
Example:
Foo doFoo() {
throw new MyCustomRunTimeException();
}
method1(){
try{
doFoo();
}catch(MyCustomRunTimeException ex){
clearcache();
throw ex;
}
}