Fandom

Wikia Developers Wiki

Global Lua Modules/User error

< Global Lua Modules

847pages on
this wiki
Add New Page
Talk0 Share

Sometimes you want your module to break, in an obvious and informative manner. The built-in error() function fills this role for developers, but is woefully unclear from the perspective of an ordinary user. This module provides a less intimidating error function, designed to warn even those who know nothing about Lua.

Comparison

error() User error
Script error Error: oh no, something broke.

Syntax

userError(message[, category1[, category2[, ...[, categoryN]]]])

Parameters

message
An error message to be displayed.
categoryN
Tracking categories to be added when message is displayed.

Examples

Throwing an error

The following code adds <strong class='error'>Error: whoops.</strong> to a page.

local p = {}
local userError = require('Dev:User error')
 
function p.main(frame)
    return userError('whoops')
end
 
return p

Adding categories

The following code adds <strong class='error'>Error: whoops.</strong> to a page, and places it in [[Category:foo]] and [[Category:bar]].

local p = {}
local userError = require('Dev:User error')
 
function p.main(frame)
    return userError('whoops', 'foo', 'bar')
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.