I think in all programming languages Exception
class is instance of Throwable
interface.
Take a look at following code which shows Exception
is not instance of Throwable
in php.
try {
throw new InvalidArgumentException("error message");
} catch (InvalidArgumentException $e) {
if ($e instanceof Exception) {
echo '$e is exception'; // this line gets executed
}
if ($e instanceof Throwable) {
echo '$e is throwable'; // but this one never
}
}
It makes problem with chaining exceptions where Exception
class constructor accepts Throwable
in it's last argument.
php version: 5.6.23
Any solution?