From f7c6cf6a8279c8c9c4d58d438bbadc08a475f25c Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sat, 16 Sep 2017 21:18:56 +0200 Subject: [PATCH] Until errors are thrown at the correct level, we'll throw it at 1. Also added `info` function. --- errors.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/errors.lua b/errors.lua index 52ffb48..496814b 100644 --- a/errors.lua +++ b/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