| This template uses Lua: |
Error is a template that outputs an HTML element with class "error" containing an error message. It can be used in other templates to signal errors, e.g. when receiving invalid arguments.
The parser function #iferror recognizes the output of this template as an error, because the output has the same format as errors produced by parser functions such as #expr or #invoke.
Usage
The template should be called with an error message. The message can be assigned to the first unnamed parameter or to the named parameter message.
{{error|I am Error}}→ I am Error{{error|message=I am Error}}→ I am Error
By default, the template will wrap the message in strong tags. A different tag can be selected by setting the named parameter tag. Accepted values are div, p, span and strong.
{{error|I am Error|tag=div}}→I am Error{{error|I am Error|tag=p}}→I am Error
{{error|I am Error|tag=span}}→ I am Error
The primary use case of the error template is to transclude it in other templates in case an error should be displayed to the user. For example, the following template "greet" creates a greeting message. It has one parameter name and uses the error template if that parameter is not set.
{{#if: {{{name|}}} | Hi there, {{{name}}}! | {{error|No name provided}} }}
TemplateData
Formats error messages as HTML.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Message | 1 message | The error message to be displayed. | Content | required |
| Tag | tag | The HTML tag for wrapping the error message.
| String | optional |