Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  





2 See also  














Module:Warning






العربية
Italiano

Oʻzbekcha / ўзбекча

Українська
 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


This module simply unifies the formatting of all warning messages similar to Module:Error. Currently, it is plain text, but custom formatting may be applied after discussion in the talk page. Warnings are displayed above the preview when previewing an edit.

Usage

local warn = require('Module:Warning')
warn("Message")
warn(("TypeWarning: %s"):format(warning), level)

See also

local libraryUtil = require('libraryUtil')

local wrapper = "%s" -- wikitext formatting
local msg_loc = "Lua warning in %s at line %d: %s."
local msg = "Lua warning: %s."

return function (message, level)
 libraryUtil.checkType('warn', 2, level, 'number', true)
 level = level or 1
 if level > 0 then
  local _, location = pcall(error, '', level+2)
  if location ~= '' then
   location = mw.text.split(location:sub(1,-3), ':%f[%d]')
   message = msg_loc:format(location[1], location[2], message)
  else
   message = msg:format(message)
  end
 else
  message = msg:format(message)
 end
 mw.addWarning(wrapper:format(message))
end

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Warning&oldid=1151467546"

Categories: 
Modules in beta
Error-handling modules
Hidden category: 
Wikipedia extended-confirmed-protected modules
 



This page was last edited on 24 April 2023, at 07:21 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki