[FLOW3-general] Render Fluid exceptions inline

Bastian Waidelich bastian at typo3.org
Thu Dec 6 12:09:54 CET 2012


Hi all,

tl;dr: do you know a good way to render exceptions inline w/o breaking 
the layout of a 3rd party markup?

I recently discussed a feature I think would make working with Fluid 
much easier (especially for starters and when dealing with routing issues).

Currently, when an error occurs while rendering a Fluid viewhelper *bam* 
an exception is thrown and you get nothing but the exception..
We already prepared the code to be extensible here in order to display 
some more context (what template/layout/partial is affected and what 
line). Nevertheless this turns out to be quite hard to implement, 
especially with compiled templates.
I'd still like this feature for some future version, but in the meantime 
we stumbled upon a compromise that seems to be a low-hanging-fruit so it 
might even make it into the upcoming version.
The idea is to catch ViewHelper exceptions in Development mode and 
render them somehow to the template.

This is as easy as replacing one line [1] from
throw $exception

to some code that returns something like:

<span style="background: red; cursor: pointer" onclick="javascript: var 
i = this.getElementsByTagName('iframe')[0]; i.style.display = 
i.style.display == 'none' ? 'block' : 'none'; return false;">
	Error!
	<iframe srcdoc="the complete exception as you know it from the 
exception handler"></iframe>
</span>

In a first really rough test this seems to work quite ok, instead of the 
exception Fluid now renders an "Error!" (see [2]) and shows the 
exception when clicking on that link (see [3]).

Obviously this looks quite ugly still and the "srcdoc" attribute is not 
supported by all browsers..

So do you know a good idea on how to render the exceptions inline 
without having to rely on external css/javascript?

A solution might be a link that renders the exception in a new window 
(all in Dev context of course)?

Best
Bastian

[1] 
http://git.typo3.org/FLOW3/Packages/TYPO3.Fluid.git?a=blob;f=Classes/TYPO3/Fluid/Core/ViewHelper/AbstractViewHelper.php;h=39e84d81b2083fc9121aa744762e5af2a3c509e7;hb=HEAD#l263

[2] 
https://www.evernote.com/shard/s17/sh/9bbea6b2-e97b-4f59-adea-0492739934ad/bc6845b58572f2ee6a1b37fb1ac3e71a/res/be95f44f-6bdb-4a54-8cae-74ee8037d41c/skitch.png

[3] 
https://www.evernote.com/shard/s17/sh/e4e2b3ac-b1c8-406c-adb1-4c86185eea88/7f204a6b188aea822337d1913c91f103/res/05ffdcb3-7725-4b71-a4d2-4dfb96c9426b/skitch.png


-- 
Bastian Waidelich
--
Core Developer Team

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the FLOW3-general mailing list