mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Lunatic: override 'error' so that a string is always returned to C.
git-svn-id: https://svn.eduke32.com/eduke32@2838 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
55d474990f
commit
1ffab1bf1a
2 changed files with 22 additions and 3 deletions
|
@ -542,8 +542,6 @@ end
|
||||||
local function errorf(level, fmt, ...)
|
local function errorf(level, fmt, ...)
|
||||||
local errmsg = string.format(fmt, ...)
|
local errmsg = string.format(fmt, ...)
|
||||||
error(errmsg, level+1)
|
error(errmsg, level+1)
|
||||||
|
|
||||||
-- XXX: error(nil) propagates to C!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local ERRLEV = 5
|
local ERRLEV = 5
|
||||||
|
@ -638,6 +636,23 @@ local function our_module(modname)
|
||||||
oG.setfenv(2, M)
|
oG.setfenv(2, M)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- overridden 'error' that always passes a string to the base 'error'
|
||||||
|
local function our_error(errmsg, level)
|
||||||
|
if (type(errmsg) ~= "string") then
|
||||||
|
oG.error("error using 'error': error message must be a string", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (level) then
|
||||||
|
if (type(level) ~= "number") then
|
||||||
|
oG.error("error using 'error': error level must be a number", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
oG.error(errmsg, level==0 and 0 or level+1)
|
||||||
|
end
|
||||||
|
|
||||||
|
oG.error(errmsg, 2)
|
||||||
|
end
|
||||||
|
|
||||||
G_.require = our_require
|
G_.require = our_require
|
||||||
G_.module = our_module
|
G_.module = our_module
|
||||||
---G_.coroutine = coroutine
|
---G_.coroutine = coroutine
|
||||||
|
@ -657,7 +672,7 @@ G_.pcall = pcall
|
||||||
--jit
|
--jit
|
||||||
---G_.bit = bit
|
---G_.bit = bit
|
||||||
--package
|
--package
|
||||||
G_.error = error
|
G_.error = our_error
|
||||||
--debug
|
--debug
|
||||||
--loadfile
|
--loadfile
|
||||||
--rawequal
|
--rawequal
|
||||||
|
|
|
@ -241,3 +241,7 @@ local bittest = require "bittest"
|
||||||
bittest.sieve()
|
bittest.sieve()
|
||||||
|
|
||||||
print('---=== END TEST SCRIPT ===---')
|
print('---=== END TEST SCRIPT ===---')
|
||||||
|
|
||||||
|
-- This will complain about wrong usage of 'error'. In particular,
|
||||||
|
-- the nil must not propagate to C!
|
||||||
|
error(nil)
|
||||||
|
|
Loading…
Reference in a new issue