Skip to content

Commit

Permalink
Merge pull request #574 from JLLK/master
Browse files Browse the repository at this point in the history
Replace Future.onFailure with Future.onComplete
  • Loading branch information
madeye committed Feb 18, 2016
2 parents ae0801b + b76d089 commit 3f08a66
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/scala/com/github/shadowsocks/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package com.github

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.util.{Success, Failure, Try}

/**
* @author Mygod
*/
package object shadowsocks {
def ThrowableFuture[T](f: => T) = Future(f) onFailure {
case e: Throwable => e.printStackTrace()

val handleFailure: PartialFunction[Try[_], Unit] = {
case Success(_) =>
case Failure(e) => e.printStackTrace()
}
}

def ThrowableFuture[T](f: => T) = Future(f) onComplete handleFailure
}

0 comments on commit 3f08a66

Please sign in to comment.