Reply to Responding to Exceptions

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация