[FLOW3-general] Exception in TypeConverters

Bastian Waidelich bastian at typo3.org
Wed Jun 1 10:48:00 CEST 2011


Fernando Arconada wrote:

Hi Fernando

> How could I catch a TypeConverter exception in a controller?

Exceptions are thrown in the convertFrom() method of some TypeConverters.
This method is called like:
AbstractController::processRequest()
   AbstractController::mapRequestArgumentsToControllerArguments()
     Argument::setValue()
       PropertyMapper::convert()
         PropertyMapper::doMapping()
           TypeConverter1::convertFrom()
           TypeConverter2::convertFrom()
           [...]

If you want to catch a certain exception you could probably override 
mapRequestArgumentsToControllerArguments() [1] in your controller and 
wrap the $argument->setValue(...) call in a try catch block.
Please note that this method is not part of the public API though!


> I only want to catch exceptions related to one parameter

For this, you probably need to write your own TypeConverter for now. E.g.:

class MyPersistentObjectConverter extends 
\F3\FLOW3\Property\TypeConverter\PersistentObjectConverter {

	protected $priority = 2; // something higher than 1

[...]
}


HTH
Bastian

[1] 
<http://git.typo3.org/FLOW3/Packages/FLOW3.git?a=blob;f=Classes/MVC/Controller/AbstractController.php;h=81c0f95ea5e94c7f98c28da172ee3c019172b107;hb=HEAD#l354>



More information about the FLOW3-general mailing list