I have a situation where it would be nice to be able to have a catch block where the type of the Exception is determined at run time. It would work something like this:
$someClassName = determineExceptionClass();
try {
$attempt->something();
} catch ($someClassName $e) {
echo 'Dynamic Exception';
} catch (Exception $e) {
echo 'Default Exception';
}
Is this at all possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…