Skip to content

Instantly share code, notes, and snippets.

@Chandler
Last active August 29, 2015 14:03
Show Gist options
  • Save Chandler/bbe15d2c2306050ee339 to your computer and use it in GitHub Desktop.
Save Chandler/bbe15d2c2306050ee339 to your computer and use it in GitHub Desktop.
//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