[TYPO3-mvc] How to catch the exceptions???

Daniel Dimitrov danielsd_bg at yahoo.fr
Thu Sep 2 15:28:16 CEST 2010


Hey,

"Franz Koch" <typo3.RemoveForMessage at elements-net.de> wrote in message 
news:mailman.1.1283427822.4048.typo3-project-typo3v4mvc at lists.typo3.org...
> Hey,
>
>> Extbase is so nice, it even throws exceptions at us :)
>>
>> What I don't understand is how to catch those Exceptions :)
>>
>> For example:
>> public function showAction(Tx_BwShop_Domain_Model_Product $product) {
>>
>> }
>>
>> If in the url we have product= something that doesn't exist extbase will
>> throw this exception:
>>
>> Tx_Extbase_MVC_Exception_InvalidArgumentValue
>>
>> The value must be of type "Tx_BwShop_Domain_Model_Product", but was of
>> type "NULL".
>>
>> How can I catch this exception and show a meaningful explanation to the
>> user???
>
> how about allowing the product to be NULL and catch this inside your 
> method? That's how I do it.
>
> public function showAction(Tx_BwShop_Domain_Model_Product $product = NULL) 
> {
>   if ($product === NULL) {
> $this->forward('invalidProduct');
> break;
>   }
>   // do your regular stuff here
> }

Hm, I didn't think of this. Well, I didn't think of this and I guess that 
I'll do it this way, but
isn't there any way to catch the exceptions? Why are we throwing them if we 
cannot
catch them :)

>
> -- 
> kind regards,
> Franz Koch

Kind regards,
Daniel 



More information about the TYPO3-project-typo3v4mvc mailing list