Search in sources :

Example 1 with VerbatimBlock

use of org.xwiki.rendering.block.VerbatimBlock in project xwiki-platform by xwiki.

the class InternalTemplateManager method generateError.

private XDOM generateError(Throwable throwable) {
    List<Block> errorBlocks = new ArrayList<Block>();
    // Add short message
    Map<String, String> errorBlockParams = Collections.singletonMap("class", "xwikirenderingerror");
    errorBlocks.add(new GroupBlock(Arrays.<Block>asList(new WordBlock("Failed to render step content")), errorBlockParams));
    // Add complete error
    StringWriter writer = new StringWriter();
    throwable.printStackTrace(new PrintWriter(writer));
    Block descriptionBlock = new VerbatimBlock(writer.toString(), false);
    Map<String, String> errorDescriptionBlockParams = Collections.singletonMap("class", "xwikirenderingerrordescription hidden");
    errorBlocks.add(new GroupBlock(Arrays.asList(descriptionBlock), errorDescriptionBlockParams));
    return new XDOM(errorBlocks);
}
Also used : XDOM(org.xwiki.rendering.block.XDOM) StringWriter(java.io.StringWriter) WordBlock(org.xwiki.rendering.block.WordBlock) ArrayList(java.util.ArrayList) GroupBlock(org.xwiki.rendering.block.GroupBlock) RawBlock(org.xwiki.rendering.block.RawBlock) VerbatimBlock(org.xwiki.rendering.block.VerbatimBlock) Block(org.xwiki.rendering.block.Block) WordBlock(org.xwiki.rendering.block.WordBlock) GroupBlock(org.xwiki.rendering.block.GroupBlock) VerbatimBlock(org.xwiki.rendering.block.VerbatimBlock) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Block (org.xwiki.rendering.block.Block)1 GroupBlock (org.xwiki.rendering.block.GroupBlock)1 RawBlock (org.xwiki.rendering.block.RawBlock)1 VerbatimBlock (org.xwiki.rendering.block.VerbatimBlock)1 WordBlock (org.xwiki.rendering.block.WordBlock)1 XDOM (org.xwiki.rendering.block.XDOM)1