Fandom Developers Wiki
Advertisement

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
Advertisement