Skip to content

Instantly share code, notes, and snippets.

@maiha
Created January 16, 2015 17:34
Show Gist options
  • Save maiha/c0bbbbfa6443cf29ef49 to your computer and use it in GitHub Desktop.
Save maiha/c0bbbbfa6443cf29ef49 to your computer and use it in GitHub Desktop.
Seq[Try[A]]
val trys: Seq[Try[CreateChatRequest]] = foo
trys.find(_.isFailure) match {
case Some(error) => ChatsCreateFailed(sid, tid, error.toString)
case None =>
val reqs = trys.map(_.get)
store.addChats(sid, tid, reqs) match {
case Success(chats) => ChatsCreateFinished(sid, tid, chats)
case Failure(error) => ChatsCreateFailed(sid, tid, error.toString)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment