Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 The rendering framework comes with a set of APIs and extensions points to deal with error reporting.
6
7 The main entry point for a code that need to produce a rendering error is the component ##org.xwiki.rendering.util.ErrorBlockGenerator##. It's job is to produce Blocks from the error which can be then be inserted in a content, it's used a lot in contexts where we don't want to stop everything when something fails (a failing macro, etc.).
8 The component takes the following metadata:
9 * ##inline##: indicate if the error is meant to be inserter in an inline content or standalone
10 * ##messageId##: the type of rendering error which is expressing (this is used as key for the translating the message and for various extension points)
11 * ##defaultMessage## and ##defaultDescription##: the default message and description to print (when no translation is associated to the provided message id). Those follow [[the SLF4J's Logger syntax>>https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Logging]]
12 * ##arguments##: the values to insert in the message and description
13
14 {{info}}
15 While the SLF4J syntax is supported in translations it's also possible to indicate explicitly the index of the parameter (##Missing macro {0}##) we want to insert which is very usefull for other languages in which the sentence structure might be very different. It's therefore recommended to be very explicit and use the indexed parameters syntax in the format of the english version located in translation resource to makes easier for translator to understand that parameters can be moved around.
16 {{/info}}
17
18 = Standard error messages
19
20 You can use any identifier you want when you use the error block generator but here are some of the standard identifiers:
21
22 * ##rendering.async.error.failed##: failed to execute asynchronous content
23 * ##uiextension.error.failed## : failed to execute UIX (id of the UIX given in the log event)
24 * ##rendering.macro.error.unknown##: unknown macro (the id of the macro is the first parameter of the log event)
25 * ##rendering.macro.error.failed##: the macro execution failed (the id of the macro is the first parameter of the log event)
26 * ##rendering.macro.error.invalid##: the macro is invalid (the id of the macro is the first parameter of the log event)
27 * ##rendering.macro.error.standalone##: a standalone macro is used inline (the id of the macro is the first parameter of the log event)
28 * ##rendering.macro.error.invalidParameter##: one of the passed parameter of a macro is invalid (the id of the macro is the first parameter of the log event)
29 * ##core.document.error.failedParse##: failed to parse the content of a document
30 * ##notification.error.failedRender##: error while rendering notification
31 * ##rendering.wikimacro.error.failedResolveContentPlaceholder##: failed to resolve macro content placeholder
32 * ##rendering.wikimacro.error.failedResolveParameterPlaceholder##: failed to resolve macro parameter placeholder
33
34 = XWiki extension points
35
36 XWiki also provides various ways to customize and extend the behavior of the error generator.
37
38 == Custom error template
39
40 A default displayer is provided for error generation but you can [[provide your own>>extensions:Extension.Template Module||anchor="HWriteatemplate"]] for a given error message identifier: the path of the template is of the form ##xwikirenderingerror/<messageId>.vm## (for example ##xwikirenderingerror/rendering.macro.error.unknown.vm##). You can also override the default error displayer by providing your own ##xwikirenderingerror/default.vm##.
41
42 == Augment the standard error displayer
43
44 The standard error displayer provides two extension points, both of which are inserted after the description:
45 * [[xwiki:Documentation.DevGuide.ExtensionPoint.Rendering Error Description]]
46 * [[xwiki:Documentation.DevGuide.ExtensionPoint.Rendering Error Type Description]]
47
48 == Bindings
49
50 Both templates and ui extension are provided with a few metadata related to the error as script bindings the entry point being the variable ##renderingerror##:
51 * messageId: the message identifier
52 * message: the message as a translated ##LogEvent##
53 * description: the description as a translated ##LogEvent##
54 * inline: indicate if the produced error is meant to be inline or standalone
55 * rootCause: the root cause Throwable in case there is a Throwable associated with the error
56 * stackTrace: the stack trace of the Throwable associated with the error
  • Powered by XWiki 13.10.3-node1. Hosted and managed by XWiki SAS

Get Connected