1
0

Metatable magic
Some checks failed
LÖVE/Lua Library / Test (push) Failing after 6s
LÖVE/Lua Library / Static-Analysis (push) Failing after 4s

This commit is contained in:
Jon Michael Aanes 2024-07-10 19:13:55 +02:00
parent 326965de6c
commit 5b0cdc5b21
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 4 additions and 1 deletions

View File

@ -132,8 +132,9 @@ end
local ErrorHandler_mt = {__call = function (self, ...) internal_error(self, '', ...) end} local ErrorHandler_mt = {__call = function (self, ...) internal_error(self, '', ...) end}
local errors = {}
return function (module_name) function errors.new(module_name)
assert(type(module_name) == 'string') assert(type(module_name) == 'string')
local err_hdl = setmetatable({}, ErrorHandler_mt) local err_hdl = setmetatable({}, ErrorHandler_mt)
@ -213,3 +214,4 @@ return function (module_name)
return err_hdl return err_hdl
end end
return setmetatable(errors, {__call = function(self, ...) return errors.new(...) end})

View File

@ -1,5 +1,6 @@
local SUITE = require 'TestSuite' 'errors' local SUITE = require 'TestSuite' 'errors'
SUITE:setEnviroment { SUITE:setEnviroment {
error = require 'errors' 'test_errors' error = require 'errors' 'test_errors'
} }