Until errors are thrown at the correct level, we'll throw it at 1. Also added info
function.
This commit is contained in:
parent
ec63ade963
commit
f7c6cf6a82
12
errors.lua
12
errors.lua
|
@ -58,7 +58,7 @@ local function internal_error (self, module_suffix, format_msg, ...)
|
|||
format_msg = format_msg or DEFAULT_ERROR_MSG_NORMAL
|
||||
assert(type(format_msg) == 'string')
|
||||
-- Format
|
||||
return error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, ...), 3)
|
||||
return error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, ...), 1)
|
||||
end
|
||||
|
||||
local function external_error (self, module_suffix, format_msg, ...)
|
||||
|
@ -75,7 +75,7 @@ local function external_error (self, module_suffix, format_msg, ...)
|
|||
level = level + 1
|
||||
end
|
||||
-- Format
|
||||
return error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, ...), level -1)
|
||||
return error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, ...), 1)
|
||||
end
|
||||
|
||||
local function correct_error (self, module_suffix, format_msg, gotten_string, possible_strings)
|
||||
|
@ -93,7 +93,7 @@ local function correct_error (self, module_suffix, format_msg, gotten_string, po
|
|||
local possible_strings = string_dist.strings_with_highest_similarity(gotten_string, possible_strings)
|
||||
local list_string = format_probable_strings(possible_strings, 3)
|
||||
-- Format
|
||||
return error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, gotten_string, list_string), 3)
|
||||
return error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, gotten_string, list_string), 1)
|
||||
end
|
||||
|
||||
----
|
||||
|
@ -159,6 +159,12 @@ return function (module_name)
|
|||
correct_error(err_hdl, '', unpack(args))
|
||||
end
|
||||
|
||||
function err_hdl.info (...)
|
||||
local args = {...}
|
||||
if args[1] == err_hdl then table.remove(args, 1) end
|
||||
return io.write(string.format(unpack(args))
|
||||
end
|
||||
|
||||
function err_hdl.register (...)
|
||||
local args = {...}
|
||||
if args[1] == err_hdl then table.remove(args, 1) end
|
||||
|
|
Loading…
Reference in New Issue
Block a user