Module:Warning

From Drifter's Wiki TEST
Jump to navigation Jump to search

Lua error: Internal error: The interpreter exited with status 127.

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



Script error: Lua error: Internal error: The interpreter exited with status 127.

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