in src/ExpectObj.hack [569:591]
public function toThrow<TException as \Throwable, TRet>(
classname<TException> $exception_class,
?string $expected_exception_message = null,
?string $msg = null,
mixed ...$args
): TException where T = (function(): TRet) {
$msg = \vsprintf($msg ?? '', $args);
$exception = $this->tryCallReturnException($exception_class);
if (!$exception) {
throw new \Exception(
$msg.': Expected exception '.$exception_class." wasn't thrown",
);
}
if ($expected_exception_message !== null) {
$message = $exception->getMessage();
$this->assertContains($expected_exception_message, $message, $msg);
}
return $exception;
}