Terraria Wiki
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Error/l10n for the localization of this template.
Template-info.svg 文档 以下文档来自Template:Error/doc。(编辑 | 历史

A helper template to display an error, generally to be used from inside other templates. Categorizes the page in Category:有模板错误的页面.


{{ error | <error text> | <additional category> }}


{{ error | text=<error text> | cate=<additional category> }}

First unnamed parameter or text

Error message to display. Will be wrapped in a span.


Hover text.

from or source

Short string denoting the source of the error. If this parameter is provided, the page will be categorized in a "有来自$source的错误的页面" category. Additionally, the span output tag will be extended to include a data-source attribute holding this parameter's value. This facilitates, for instance, easy access of errors from the same source via JavaScript or CSS.

Second, third, ..., n-th unnamed parameter and cate, cate2, ..., cate<n>

Additional categories to categorize the page in, can be continued ad infinitum. Set $cate to n or no to prevent categorization altogether.


Code Result Categories added
{{error|Something went wrong!}} !!Error: Something went wrong!
{{error|Something went wrong!|from=MyTemplate}} !!Error: Something went wrong!
{{error|Something went wrong!|from=MyTemplate|cate=n}} !!Error: Something went wrong!
{{error|Something went wrong!|from=MyTemplate|cate=Things to do|cate2=Pages with script errors}} !!Error: Something went wrong!

Error handling

The output of this template is compatible with the {{#[[[:Template:Tl/parser function links]]##iferror iferror]:}} parser function, which can be used to catch and handle errors.

Code Result
{{error|Fault!}} !!Error: Fault!
{{#iferror:{{error|Fault!}}|There is something wrong!|Everything is OK.}} There is something wrong!
{{#iferror:{{error|Fault!}}|There is something wrong!}} There is something wrong!
{{#iferror: {{error|Fault!}} }} (no output)