Created
July 31, 2014 21:02
-
-
Save Chandler/8650a3ad05e79495a317 to your computer and use it in GitHub Desktop.
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
| case class MyException(errorCode: Int) extends RuntimeException | |
| def onThrow[T <: Throwable](check: Check[T])(implicit m: Manifest[T]): Check[Try[_]] = | |
| expected("A Throw(e: %s)".format(m.erasure)).exceptWhen { case Throw(NonFatal(e: T)) => check(e) } | |
| val check = onThrow { | |
| hasType[Unauthorized.type].on { e: ClientError => e.errorCause } | |
| } | |
| check(Throw(MyException(5))) | |
| res3: com.twitter.coreservices.integration.TestResult = TestResult(HierarchicalLog(List(Value(Entry(2014-07-31 21:02:22 +0000, | |
| Error(java.lang.ClassCastException: MyException cannot be cast to com.twitter.servo.exception.thriftscala.ClientError)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment