Template:Formatting error/doc

From Freeside Atlanta
< Template:Formatting error
Revision as of 18:30, 16 February 2013 by Emptyset (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

{{#ifeq: doc | doc

 | 

{{

   #ifeq: show | show
   | {{#invoke:Message box|mbox}}
   }}{{
   #if: 
   | 
   | {{#ifexist:Template:Formatting error|[[Category:{{
     #switch: Template
     | Template  = Template
     | Module  = Module
     | User      = User
     | #default  = Wikipedia
   }} documentation pages]]|}}
 }}

| }} 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|<{{#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|<{{#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|<{{#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|<{{#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|<{{#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}}}|<{{#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}}}||<{{#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}}}||<{{#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:UnicodeTemplate:Val/delimitnum}}}}}}{{#if:|×10Template:Val/delimitnum}}|{{#if:|10Template:Val/delimitnum}}}}{{#if:| Template:Val/units}}{{#if:| Template:Val/unitswithlink}}{{#if:|/Template:Val/units}}{{#if:|/Template:Val/unitswithlink}}}}}}}}}}}}}}}}}}|error|OK}}

See also