|
Posted by e_matthes on 02/24/07 22:17
Hello everyone,
I have set up some custom exceptions, and have managed to implement
the proper responses to those exceptions. I have something like this:
try {
do something;
} catch (ExceptionA $e) {
response;
} catch (ExceptionB $e) {
response;
} catch (ExceptionC $e) {
response;
} catch (ExceptionD $e) {
response;
} catch (Exception $e) {
respond to unknown exception;
}
It's a little clunky though, because sometimes responses to Exceptions
B, C, and D are the same. Is there any way to collect those specific
exceptions together in a specific response situation? In other words,
what I'd love to do is:
try {
do something;
} catch (ExceptionA $e) {
response;
} catch (ExceptionB $e OR ExceptionC $e OR ExceptionD $e) {
response;
} catch (Exception $e) {
respond to unknown exception;
}
I know I could catch Exception A, then catch the parent Exception
class, then $e->getcode, and respond to the code in an if-else clause
or switch clause. But is there any way to do this with the exceptions
themselves, i.e. catch a group of exceptions together? Thanks.
[Back to original message]
|