Hi,

I'd like to tackle the error rendering part of the new rendering module.
Right now there are several locations where the rendering can fail:
* a Macro can fail to be located
* a Macro can fail during execution
* a link can fail to be resolved. For example if the access to the  
database fails when looking up the document corresponding to the link  
name. Or if the link has an invalid format.

WikiModel will normally not generate any exception while parsing so we  
shouldn't have any exception to handle there. Haven't checked Doxia  
yet on this.

In any case I see 2 options to handle the cases listed above:

Solution 1: Generate an ErrorBlock
===========================

This means replacing the original block (MacroBlock or LinkBlock) by  
an ErrorBlock which will then get rendered accordingly (with some kind  
of error box in the XHTML renderer for example).

Pros: Shows exactly where the problem is in the document and render  
the rest of the document.
Cons: It's possible to overlook the fact that there's a rendering  
error since it doesn't blow up when an error happens

Solution 2: Fail the rendering process with an exception
===========================================

We'll then need some error handling code in XWiki to handle exceptions  
thrown by the XDOM.traverse() method.

Pros: Not possible to avoid the fact that there's an error in the  
document somewhere
Cons: Makes rendering process more "fragile" and possibly make it  
harder to find out where the problem is located. Note that to  
alleviate this we would need to implement some code to tell the user  
where the problem happened exactly in the code (this could be done by  
adding some offset/length attributes to the Blocks).

Personally I'm still hesitating but I think maybe the best would be to  
combine both solutions, i.e. do the following:
* Generate the rendered document with rendered ErrorBlocks
* Throw an exception which contains the rendered document, thus  
allowing the error handling the ability display the rendered document  
with its errors displayed inline.

WDYT?

Thanks
-Vincent


_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to