Last active
August 29, 2015 14:03
-
-
Save Chandler/bbe15d2c2306050ee339 to your computer and use it in GitHub Desktop.
This file contains 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
//this works | |
def checkUnauthorizedException[T](t: Try[T]): TestResult = | |
t match { | |
case Throw(e) if e.isInstanceOf[UnauthorizedException] => TestResult.Success | |
case _ => TestResult.fail("found " + t.toString() + " but expected Throw[UnauthorizedException]") | |
} | |
//possible to make this more generic? e.g. something like.. | |
def checkThrow[T](found: Try[T], magical_type_parameter): TestResult = | |
t match { | |
case Throw(t) if t.isInstanceOf[magical_type_parameter] => TestResult.Success | |
case Throw(_) => TestResult.fail("Throw wasn't the correct type") | |
case Return(_) => TestResult.fail("Try was a Return") | |
} | |
//so I could do | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment