Quite simply an undefined method isn't the code throwing an exception.
try{
throw new Exception;
}
catch(RuntimeException $e){
echo 'Runtime exception called';
}
catch(BadFunctionCallException $e){
echo 'Bad function call exception called';
}
catch(Exception $e){
echo 'General exception called';
}
You can also pass and call messages through in your exceptions and write them out in the catch block:
try{
throw new Exception('some useful error message');
}
catch(RuntimeException $e){
echo 'Runtime exception called';
}
catch(BadFunctionCallException $e){
echo 'Bad function call exception called';
}
catch(Exception $e){
echo $e->getMessage();
}
This is the same for the other type of exceptions you mention:
try{
throw new RuntimeException;
}
catch(RuntimeException $e){
echo 'Runtime exception called';
}
catch(BadFunctionCallException $e){
echo 'Bad function call exception called';
}
catch(Exception $e){
echo 'General exception called';
}
And
try{
throw new BadFunctionCallException;
}
catch(RuntimeException $e){
echo 'Runtime exception called';
}
catch(BadFunctionCallException $e){
echo 'Bad function call exception called';
}
catch(Exception $e){
echo 'General exception called';
}