1
0

Improved error checking messages for strings_with_highest_similarity.

This commit is contained in:
Jon Michael Aanes 2017-08-27 11:47:05 +02:00
parent 7b9b9d2912
commit 9d94601f83

View File

@ -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 = {}