Metatable magic
This commit is contained in:
parent
326965de6c
commit
5b0cdc5b21
|
@ -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})
|
||||||
|
|
|
@ -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'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user