[Typo3-dev] Concept for exception handling?
Robert Lemke
robert at typo3.org
Thu Feb 10 19:46:35 CET 2005
Ries van Twisk wrote:
> I agree.... it will take at least a couple of more years untill PHP5 is
> wide spread into ISP land... Not for our offices etc...
I don't think it will be several years. I will definately use PHP5 for the
next major version of the Documents Suite and I could imagine TYPO3 using
PHP5 features in a year from now. But you never know of course ...
> btw... I currently can't see a big advantage for exeption handeling in
> PHP... but that's just my huble opinion.,
I do. In my opinion code with PHP5 exceptions comes more readable.
See this simple example:
PHP4
if ($docFactoryObj = myClass::getNewDocFactory()) {
if ($documentObj = $docFactoryObj->newDocument()) {
if ($documentObj->load('mydocument.sxw')) {
...
} else { printerror ('could not load');
} else { printerror ('could not create new document');
} else { printerror ('could not get new factory');
PHP5
try {
$docFactoryObj = myClass::getNewDocFactory();
$documentObj = $docFactoryObj->newDocument();
$documentObj->load('mydocument.sxw');
} catch (docException $exception) {
printerror ($exception);
}
--
robert
More information about the TYPO3-dev
mailing list