Fantasy Forums - Fantasy Cafe 2012 Fantasy Cafe


Template:FormattingError/doc

{{#ifeq: formattingerror/doc | doc

 | 

{{

   #ifeq: show | show
   | {{
 {{#switch:
 {{#if: 
   | 
   | {{#if: 
     | 
       {{#ifeq:{{namespace:{{{page}}} }}|{{talkspace:{{{page}}} }}
       | talk
       | {{subjectspace:{{{page}}} }} 
       }}
     | 
       {{#ifeq:template|template talk
       | talk
       | template 
       }}
     }}
   }}

| main | = ambox | talk = tmbox | user = ombox | wikipedia = ombox | file | image = imbox | mediawiki = ombox | template = ombox | help = ombox | category = cmbox | portal = ombox | book = ombox | other | #default = ombox

}} | type = notice | image = 40px | imageright = | style = | textstyle = | text = This is a documentation subpage for Template:FormattingError/doc.
It contains usage information, categories, interlanguage links and other content that is not part of the original {{ #if: | {{{text2}}} | {{ #if: | {{{text1}}} | {{ #ifeq: Template | User | template template page | {{ #if: Template |template page|article}}}}}}}}. | small = | smallimage = | smallimageright = | smalltext = }}

   }}{{
   #if: 
   | 
   | [[Category:{{
     #if: Template
     | Template
     | Article
   }} documentation]]
 }}

| }} Outputs an error message in red into the page and adds the page to Category:Pages with incorrect formatting templates use. An anchor (FormattingError) is inserted at the start of the error message, so you can find any errors on a page easily by adding #FormattingError at the end of the URL (e.g. Template:val/test#FormattingError). Used in complex templates that check their arguments for validity, so incorrect use can be spotted while editing a page or afterwards.

Usage

  • {{FormattingError|error message}}

or

  • {{FormattingError|error message|nocategory=true}}

When using the nocategory argument, the error message is displayed as usual, but the page is not added to Category:Pages with incorrect formatting templates use. This is useful in documentation pages for templates that use FormattingError and show what errors they can generate without adding these documentation pages to the category. For an example of this, see {{LinkForElement}}.

This template can be evaluated using the {{#iferror}} parser function:

  • {{#iferror:{{val|XX}}|error|OK}}{{#iferror:{{#ifeq:{{#if:XX|{{#ifeq:XX|{{#if:{{#ifexpr:{{#expr:XX}}}}|(XX)|{{#expr:XX}}}}|true|{{#ifeq:XX|+{{#if:{{#ifexpr:{{#expr:XX}}}}|(XX)|{{#expr:XX}}}}|true|{{#ifeq:XX|({{#if:{{#ifexpr:{{#expr:XX}}}}|(XX)|{{#expr:XX}}}})|true|false}}}}}}}}|false|<span id="FormattingError" /><{{#switch:{{{tag}}}
|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: first argument is not a valid number or requires too much precision to display.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifeq:{{#if:0|{{#ifeq:0|{{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}}|true|{{#ifeq:0|+{{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}}|true|{{#ifeq:0|({{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}})|true|false}}}}}}}}|false|<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: second argument is not a valid number or requires too much precision to display.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifeq:{{#if:0|{{#ifeq:0|{{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}}|true|{{#ifeq:0|+{{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}}|true|{{#ifeq:0|({{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}})|true|false}}}}}}}}|false|<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: third argument is not a valid number or requires too much precision to display.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifexpr: -1 >= 0|<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: third argument is not negative.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifeq:{{#if:0|{{#ifeq:0|{{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}}|true|{{#ifeq:0|+{{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}}|true|{{#ifeq:0|({{#if:{{#ifexpr:{{#expr:0}}}}|(0)|{{#expr:0}}}})|true|false}}}}}}}}|false|<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: exponent (e) is not a valid number or requires too much precision to display.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifeq:|{{{upl}}}|<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: unit (u or ul) is not specified but units per (up or upl) is.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifeq:{{{u}}}{{{ul}}}||<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: unit (u) and units with link (ul) are both specified, only one is allowed.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#ifeq:{{{up}}}{{{upl}}}||<span id="FormattingError" /><{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}} class="error">Error in {{val}}: unit per (up) and units per with link (upl) are both specified, only one is allowed.</{{#switch:{{{tag}}}

|p=p
|span=span
|div=div
|#default=strong

}}>{{#switch:Template |Talk |User |User_talk |Template:Ns:Wikipedia talk= |#default={{#if:||}} }}|{{#if: XX|Template:Val/delimitnum{{#if: |{{#if: |Template:Su|{{#if:{{#ifexpr: 0{{{2}}}}}|{{{2}}}|±Template:Val/delimitnum}}}}}}{{#if:|×10Template:Su}}|{{#if:|10Template:Su}}}}{{#if:| Template:Val/units}}{{#if:| Template:Val/unitswithlink}}{{#if:|/Template:Val/units}}{{#if:|/Template:Val/unitswithlink}}}}}}}}}}}}}}}}}}|error|OK}}

See also