[TYPO3-core] Exceptions in FAL

Ernesto Baschny [cron IT] ernst at cron-it.de
Mon Sep 16 13:50:27 CEST 2013


Hi Francois,

also going more offtopic, but I think the whole Exception "best
practices" in TYPO3 need to be specified one time. Now that we are on
PHP 5.3 base as a minimum, we might also want to take a look on when (or
when not) to use nested exceptions in our Catch blocks.

By defining some convention (i.e. a marker exception interface per
"component"), inheriting from SPL Exceptions, would especially help
"optimize" the try/catch blocks and give more flexibility on how to
handle the exception.

Worthy read for this is [1] and to also to see how others like PEAR2 [2]
and Zend Framework [3] are defining their "best practices" when it comes
to Exceptions. We might want to lend some ideas from that to our guidelines.

Cheers,
Ernesto

[1] http://ralphschindler.com/2010/09/15/exception-best-practices-in-php-5-3
[2] https://wiki.php.net/pear/rfc/pear2_exception_policy
[3]
http://framework.zend.com/wiki/display/ZFDEV2/Proposal+for+Exceptions+in+ZF2


François Suter schrieb am 16.09.2013 12:01:
> Hi Steffen,
> 
>>> Which way should this be fixed? Should the
>>> InsufficientFileAccessPermissionsException be added to the exceptions
>>> caught by ExtendedFileUtility?
>>
>> Yes, I think so.
> 
> OK.
> 
>> Should it replace
>>> InsufficientUserPermissionsException?
>>
>> No, because the reasons are different, the one comes from the Driver
>> (therefore filesystem), the other one from TYPO3 (beuser permissions)
> 
> I see.
> 
>> Or should the Resource rather trow
>>> InsufficientUserPermissionsException?
>>
>> If it's a restriction from TYPO3, yes.
> 
> It is indeed, in this case.
> 
>>> Furthermore it seems to me that the resource being a Folder in this case
>>> should throw a InsufficientFolderAccessPermissionsException rather than
>>> a InsufficientFileAccessPermissionsException.
>>
>> Hm, a folder is a kind of file, too :)
> 
> Sure, but then why do we have separate models and separate exceptions?
> The InsufficientFolderAccessPermissionsException exists, so I guess we
> should use them.
> 
>>> And do we need so many exceptions? Isn't it a bit too fine-grained in
>>> this particular case?
>>
>> The last two questions (FolderAccess vs. FileAccess and
>> too-fine-grained) I cannot answer right now - I would need to see the
>> actual case.
> 
> Well, I was just looking at the long list of exceptions and wondering
> whether it made sense to have so many, but that's slightly off the topic
> of my initial question and is probably more a matter of taste.
> 
> Cheers
> 



More information about the TYPO3-team-core mailing list