Hey, it seem like when using `Try` it’s common to ...
# arrow
r
Hey, it seem like when using
Try
it’s common to want to write to a log if an exception occurs. I’ve currently been using a pattern like the following, but I’m curious if there’s a more succinct or abstract way I can go about this:
Copy code
Try { db.update(model) }
   .toEither {
       logger.error("My message", it.localizedMessage)
       it
   }
   .fold(
       { /*handle failure*/ },
       { /*handle success*/ }
    )
Thoughts on how to better handle this?
g
you could use mapLeft()
r
I don’t believe try has mapLeft
At least not in the version I’m on