「モジュール:Protect」の版間の差分
表示
ja>ネイ 日本語化 |
細 1版 をインポートしました: Main, Pathnavなど |
(相違点なし)
|
2025年1月11日 (土) 22:56時点における最新版
このモジュールについての説明文ページを モジュール:Protect/doc に作成できます
local function processResult(options, success, ...)
if not success then
local message = tostring(... or '(メッセージなし)')
if options.removeLocation then
message = string.gsub(message, '^Module:[^:]+:%d+: ', '', 1)
message = string.gsub(message, '^モジュール:[^:]+:%d+: ', '', 1)
end
return string.format(options.errFormat, message)
end
return ...
end
local function protect(func, errFormat, options)
if type(errFormat) == 'table' then
options = options or errFormat
errFormat = nil
end
options = mw.clone(options) or {}
options.errFormat = errFormat or options.errFormat or 'エラー: %s'
if not options.raw then
options.errFormat = '<strong class="error">' .. options.errFormat .. '</strong>'
end
options.removeLocation = options.removeLocation == nil or options.removeLocation
return function (...)
return processResult(options, pcall(func, ...))
end
end
return protect