Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:CallAssert/doc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Module rating|r}} {{used in system}} This [[Help:Lua metamodules|metamodule]] provides function '''callAssert''', which simplifies error checking by throwing an error if a given function returns nil or false. This is similar to the built-in function [[mw:LUAREF#assert|assert]], but unlike it, callAssert itself calls the function, whose return value is to be checked. This allows it to include the function name and argument values in the error message. == Usage == local callAssert = require('Module:CallAssert') local result1, result2, etc = '''callAssert(''func'', {{'}}''funcName''{{'}}, ...)''' <code>callAssert</code> calls <code>''func''(...)</code> and checks if the first returned value evaluates to true. If it does, then it returns all the returned values. If not, it throws an error with a message in the form <code>{{'}}''funcName''(''argument_values'') failed'</code>. <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | [[Category:Error-handling modules]] }}</includeonly>
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:'
(
edit
)
Template:Module rating
(
edit
)
Template:Sandbox other
(
edit
)
Template:Used in system
(
edit
)
Module:High-use
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:String
(
edit
)
Module:Transclusion count
(
edit
)
Module:Transclusion count/data/C
(
edit
)
Module:Yesno
(
edit
)