You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try {
$callback();
} catch (\Exception$e) {
if (!$e instanceof $class) {
$this->fail(sprintf("Exception of class $class expected to be thrown, but %s caught", get_class($e)));
}
I propose catching \Throwable and doing the check.
The text was updated successfully, but these errors were encountered:
What are you trying to achieve?
I'm trying to catch a
TypeError
.What do you get instead?
Since
expectException()
only checks the class of anything that's a subclass of\Exception
, throwables like\TypeError
are not caught.Snippet from https://github.com/Codeception/Codeception/blob/2.4/src/Codeception/Module/Asserts.php#L437
I propose catching
\Throwable
and doing the check.The text was updated successfully, but these errors were encountered: