Wednesday, 15 June 2011

Scala - Try with exception logging -



Scala - Try with exception logging -

scala's try useful. i'd utilize pattern, log exceptions. how can this?

define next helper:

import scala.util.{try, failure} def logtry[a](computation: => a): try[a] = { try(computation) recoverwith { case e: throwable => log(e) new failure(e) } }

then can utilize use try, exception logged through log(e).

scala exception logging

No comments:

Post a Comment