[nycphp-talk] Setting a catch dynamically
Rob Marscher
rmarscher at beaffinitive.com
Fri Dec 14 15:08:16 EST 2007
> Ben Sgro wrote:
>> try
>> {
>> call_user_func($faSet, $this->getArguments($argSet));
>> }
>> catch ( customException $e )
>> {
>> throw new $exceptionToThrow;
>> }
On Dec 14, 2007, at 2:59 PM, Ben Sgro wrote:
> I want to set the customException dynamically.
> I tried doing so by passing it in as a var ... catch ($var $e)
> but that didn't seem to work.
> Can it be done?
I'm not sure... seems somewhat odd that you would need to do that...
You could catch Exception which would get you everything and then use
a switch on get_class:
try {
// something
} catch (Exception $e) {
switch (get_class($e)) {
default:
// blah
break;
case $customException:
// handle it
break;
}
}
More information about the talk
mailing list