diff --git a/string_distance.lua b/string_distance.lua index 3091744..f9a90ea 100644 --- a/string_distance.lua +++ b/string_distance.lua @@ -175,9 +175,11 @@ local function strings_with_highest_similarity (str, list_of_other_str) -- the output list is the most similar. -- Error checking - assert(type(str) == 'string') - assert(type(list_of_other_str) == 'table') - for i = 1, #list_of_other_str do assert(type(list_of_other_str[i]) == 'string') end + if type(str) ~= 'string' then error(('[errors/internal]: Bad argument #1, expected string, got %s (%s)'):format(str, type(str))) end + if type(list_of_other_str) ~= 'table' then error(('[errors/internal]: Bad argument #2, expected table, got %s (%s)'):format(list_of_other_str, type(list_of_other_str))) end + for i = 1, #list_of_other_str do + if type(list_of_other_str[i]) ~= 'string' then error(('[errors/internal]: Bad argument #2, expected sequence of strings, but got %s (%s) on index %i'):format(list_of_other_str[i], type(list_of_other_str[i])), i) end + end -- Do work local possible = {}