Created
August 7, 2012 13:57
-
-
Save ahoy-jon/3285561 to your computer and use it in GitHub Desktop.
Pick your poison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val log = new {def warn(a:Any) {}} | |
val timeoutWarn = () => log.warn("Actor ask timed-out while calling HttpClient") | |
def handleTimeouts[A](response : Option[(Int, Option[String])], | |
method : (Int, Option[String]) => List[A]):List[A] = { | |
// method application .... or warning on timeout and emptyList | |
response.map(method.tupled(_)).getOrElse({timeoutWarn(); List.empty[A]}) | |
} | |
def handleTimeouts2[A](response : Option[(Int, Option[String])], | |
method : (Int, Option[String]) => List[A]):List[A] = { | |
// method application or warning on timeout | |
response match { | |
case Some(res) => method.tupled(res) | |
case None => timeoutWarn(); List.empty[A] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment