[TYPO3-mvc] Non existing object: how to handle the error?

Steffen Ritter info at rs-websystems.de
Mon Feb 21 16:39:15 CET 2011


Am 21.02.2011 16:35, schrieb Dmitry Dulepov:
> Hi all!
>
> (Disclamer: I am learning)
>
> While playing with blog_example, I changed the URl manually: I set
> non-existing blog id. The result is expected: I got the exception from
> Extbase:
>
> #1251730701: The value must be of type
> "Tx_BlogExample_Domain_Model_Blog", but was of type "NULL".
>
> The question is: would it be possible to catch that error and show more
> sensible error to the user? I am sure it is possible, but how?
>
What i do:

changing
showAction(Tx_MyExt_MyModel $model) {

to

showAction(Tx_MyExt_myModel $model = NULL) {
if ($model === NULL) {
	$this->throwStatus('404', NULL, '<p>I will insert a fancy error message 
at the plugin place</p>');
}

The Error Message might be plain, text, translated or - how I do: create 
error message Templates end render them using fluid ;)

regards

Steffen



More information about the TYPO3-project-typo3v4mvc mailing list