private void generateError(MacroBlock macroToReplace, String message, String description) { List<Block> errorBlocks = new ArrayList<Block>(); Map<String, String> errorBlockParams = Collections.singletonMap("class", "xwikirenderingerror"); Map<String, String> errorDescriptionBlockParams = Collections.singletonMap("class", "xwikirenderingerrordescription hidden"); Block descriptionBlock = new VerbatimBlock(description, macroToReplace.isInline()); if (macroToReplace.isInline()) { errorBlocks.add(new FormatBlock(Arrays.<Block> asList(new WordBlock(message)), Format.NONE, errorBlockParams)); errorBlocks.add(new FormatBlock(Arrays.asList(descriptionBlock), Format.NONE, errorDescriptionBlockParams)); } else { errorBlocks.add(new GroupBlock(Arrays.<Block> asList(new WordBlock(message)), errorBlockParams)); errorBlocks.add(new GroupBlock(Arrays.asList(descriptionBlock), errorDescriptionBlockParams)); } macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace); }
/** * Generates Blocks to signify that the passed Macro Block has failed to execute. * * @param macroToReplace the block for the macro that failed to execute and that we'll replace with Block * showing to the user that macro has failed * @param message the message to display to the user in place of the macro result * @param description the long description of the error to display to the user in place of the macro result */ public void generateError(MacroBlock macroToReplace, String message, String description) { List<Block> errorBlocks = this.errorBlockGenerator.generateErrorBlocks(message, description, macroToReplace.isInline()); macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace); }
/** * Generates Blocks to signify that the passed Macro Block has failed to execute. * * @param macroToReplace the block for the macro that failed to execute and that we'll replace with Block * showing to the user that macro has failed * @param message the message to display to the user in place of the macro result * @param throwable the exception for the failed macro execution to display to the user in place of the macro result */ public void generateError(MacroBlock macroToReplace, String message, Throwable throwable) { List<Block> errorBlocks = this.errorBlockGenerator.generateErrorBlocks(message, throwable, macroToReplace.isInline()); macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace); }
.getContent(), xdom.getChildren(), htmlMacroBlock.isInline()); htmlMacroMarker.setParent(htmlMacroBlock.getParent());
htmlMacroBlock.getParent().replaceChild(htmlMacroMarker, htmlMacroBlock);
macroHolder.macroBlock.getParent().replaceChild(resultBlock, macroHolder.macroBlock);
wikiMacroBlock.getParent().replaceChild(syncMetaDataBlock, wikiMacroBlock);
resolvedRootBlock = context.getCurrentMacroBlock().getParent(); } else { resolvedRootBlock = context.getXDOM();