0
votes

I have a query that output some very inconvenient error message:

Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT p, e, c FROM Entity\Event e LEFT JOIN e.place p INNER JOIN e.categories c WITH c MEMBER OF :cat WHERE (e.dateStart BETWEEN :from AND :to) AND (p.latitude BETWEEN :minLat AND :maxLat) AND (p.latitude BETWEEN :minLat AND :maxLat) AND (p.latitude BETWEEN :minLat AND :maxLat) AND (p.longitude BETWEEN :minLng AND :maxLng) ORDER BY e.dateStart ASC' in /Users/YohannM/Sites/meetmyfriends-back/application/libraries/Doctrine/ORM/Query/QueryException.php:39Stack trace:#0 /Users/YohannM/Sites/meetmyfriends-back/application/libraries/Doctrine/ORM/Query/Parser.php(429): Doctrine\ORM\Query\QueryException::dqlError('SELECT p, e, c ...')#1 /Users/YohannM/Sites/meetmyfriends-back/application/libraries/Doctrine/ORM/Query/Parser.php(528): Doctrine\ORM\Query\Parser->semanticalError('':cat' is not d...', Array)#2 /Users/YohannM/Sites/meetmyfriends-back/application/libraries/Doctrine/ORM/Query/Parser.php(233): Doctrine\ORM\Query\Parser->_processDeferred in /Users/YohannM/Sites/meetmyfriends-back/application/libraries/Doctrine/ORM/Query/QueryException.php on line 49

As you can see, this is very inconvenient for debugging as my errors are truncated: Parser->semanticalError('':cat' is not d...',.

I have tried to vardump the excpetion but chrome crashes as the results returned is over 1GB !!

So my question is, how do I output the errors nicely. I'm not working with symfony2 but with Codeingniter

Thanks

1
Why can't you use standard try... catch... ? - dmnptr
I can't vardump the exception, its too big and my browser crash. I can see there are hundreds of megabytes transfered (everytime I vardunp a doctrine entity, it crashes for no reason, I can se in the chrome console that its over 700Mb, I have no idea why) - Miles M.
if you want to vardump an exception, you should use `\Doctrine\Common\Util\Debug::dump($object)' utility. See my answer for more - dmnptr

1 Answers

1
votes

You should not use vardump to dump an exception. Many Doctrine classes are interlinked, so, when you try to vardump an exception, it creates a recursion, and that is why your browser exhausts available memory and crashes.

Doctrine has a utility that allows you to dump interlinked objects and specify the level of recursion. For example, to dump an object and all linked object up to 5 levels deep use this:

\Doctrine\Common\Util\Debug::dump($object, 5);

The default depth level is 2. More info - http://www.doctrine-project.org/api/common/2.4/class-Doctrine.Common.Util.Debug.html