Module:Decimals: Difference between revisions
Content added Content deleted
Vivaporius (talk | contribs) m (1 revision imported) |
en>Vivaporius (Created page with "require('Module:No globals') local p = {} function p._main(n, d) local num = tonumber(n) if not num then error('Unable to convert "' .. tostring(n) .. '" to a number')...") |
||
Line 25: | Line 25: | ||
function p.main(frame) |
function p.main(frame) |
||
local args, pargs = frame.args, frame:getParent().args |
local args, pargs = frame.args, frame:getParent().args |
||
local function work() |
|||
⚫ | |||
return p._main( |
|||
⚫ | |||
mw.ext.ParserFunctions.expr(args[2] or pargs[2]) |
|||
) |
|||
end |
|||
local success, result = pcall(work) |
|||
if success then |
|||
return result |
|||
end |
|||
local errtext = args.error or pargs.error |
|||
if errtext then |
|||
return errtext |
|||
end |
|||
error(result, 0) |
|||
end |
end |
||