Title: Module:Error - freem URL Source: https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError Markdown Content: Revision as of 15:10, 11 September 2025 by [en>Ahecht](https://freemwiki.com/wiki/User:Ahecht "en:User:Ahecht") ![Image 1](https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Green_check.svg/40px-Green_check.svg.png)This [module](https://en.wikipedia.org/wiki/Module "wikipedia:Module") is rated as [ready for general use](https://freemwiki.com/index.php?title=Category:Modules_for_general_use&action=edit&redlink=1 "Category:Modules for general use (page does not exist)"). It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on [help pages](https://en.wikipedia.org/wiki/Help_pages "wikipedia:Help pages") and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through [sandbox testing](https://en.wikipedia.org/wiki/Template_sandbox_and_test_cases "wikipedia:Template sandbox and test cases") rather than repeated trial-and-error editing. This module implements {{[Error](https://freemwiki.com/index.php?title=Template:Error&action=edit&redlink=1 "Template:Error (page does not exist)")}}. It creates an html message with class "error". Please, see the documentation page there for usage instructions. ## See also * [Module:Warning](https://freemwiki.com/index.php?title=Module:Warning&action=edit&redlink=1 "Module:Warning (page does not exist)") * [Module:If preview](https://freemwiki.com/index.php?title=Module:If_preview&action=edit&redlink=1 "Module:If preview (page does not exist)") * * * [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-1)-- This module implements {{[error](https://freemwiki.com/wiki/Template:Error "Template:Error")}}.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-2)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-3)local p = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-4)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-5)function p._error(args)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-6) local tag = mw.ustring.lower(tostring(args.tag))[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-7)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-8) -- Work out what html tag we should use.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-9) if not (tag == 'p' or tag == 'span' or tag == 'div') then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-10) tag = 'strong'[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-11) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-12)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-13) -- Generate the html.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-14) return tostring(mw.html.create(tag)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-15) :addClass('error')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-16) :cssText(args.style)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-17) :wikitext(tostring(args.message or args[1] or error('no message specified', 2)))[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-18) )[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-19)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-20)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-21)function p.error(frame)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-22) local args[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-23) if type(frame.args) == 'table' then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-24) -- We're being called via #invoke. The args are passed through to the module[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-25) -- from the template page, so use the args that were passed into the template.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-26) args = frame.args[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-27) else[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-28) -- We're being called from another module or from the debug console, so assume[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-29) -- the args are passed in directly.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-30) args = frame[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-31) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-32) -- if the message parameter is present but blank, change it to nil so that Lua will[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-33) -- consider it false.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-34) if args.message == "" then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-35) args.message = nil[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-36) end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-37) return p._error(args)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-38)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-39)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&oldid=579543&title=Module%3AError#L-40)return p