VAIBHAV JAIN
VAIBHAV JAIN

Reputation: 19

How to use .onFailure in scala Future?

My scenario is that suppouse for now I have a function abc() which has a return type of Future[Unit](or it can also have a return type ) , now someone has given me a task that if this abc function failes it just print a logger statement and that's it , it should not fail the parent function inside which it is wrapped around , and he also recommended me to use Future.onFailure . Now what I have tried is

abc(some , random ,code ).onFailure(e=>{
    logger.debug("I don't want to through error : ${e}")
})

But intellij is showing me this

enter image description here

I am not able to understand what does this error means ? What should be way out for this ? And if possible please explain more about onFaiure in Futures with examples

Thanks in advance

Upvotes: 0

Views: 414

Answers (0)

Related Questions