Robert Menke
05/17/2019, 5:38 PMTry
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:
Try { db.update(model) }
.toEither {
logger.error("My message", it.localizedMessage)
it
}
.fold(
{ /*handle failure*/ },
{ /*handle success*/ }
)
Thoughts on how to better handle this?gjesse
05/17/2019, 5:43 PMRobert Menke
05/17/2019, 5:46 PMRobert Menke
05/17/2019, 5:46 PM