모듈:Protect
위 설명은 모듈:Protect/설명문서의 내용을 가져와 보여주고 있습니다. (편집 | 역사) 이 틀에 대한 수정 연습과 시험은 연습장 (만들기)과 시험장 (만들기)에서 할 수 있습니다. 분류는 /설명문서에 넣어주세요. 이 문서에 딸린 문서. |
local function processResult(options, success, ...)
if not success then
local message = tostring(... or '(메시지 없음)')
if options.removeLocation then
message = string.gsub(message, '^(Module|모듈):[^:]+:%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