[TYPO3-mvc] 404 redirect if requested object doesn't exist? show action

Franz Koch typo3.RemoveForMessage at elements-net.de
Wed Apr 20 14:43:11 CEST 2011


Hey,

>> [FE][pageNotFoundOnCHashError] = 1
>> solved my special problem. if i had an old link with chash bookmarked
>> then i got the
>> Uncaught TYPO3 Exception
>> #1251730702: The value must be of type "Tx_Myext_Domain_Model_Articles",
>> but was of type "NULL".
>> now it's redirecting.
>> isn't there any way to do try catch?
>
> I stumbled on this issue too and I have the same question.
>
> Setting [FE][pageNotFoundOnCHashError] = 1 works fine and is a possible
> solution, but I would like to redirect my users to some other view (e.g.
> a list view) instead of sending them to the generic 404 page.
>
> So is there any place within the Controller where the above exception
> can be caught and acted upon?

simply allow the property to be NULL and check that in your controller 
action.

public function show(Tx_Foo_..._Item $item = NULL) {
	if ($item === NULL) {
		# throw 404 and redirect ...
	}
}

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list