mirror of
https://github.com/TangentFoxy/.lua-files.git
synced 2024-11-20 21:34:23 +00:00
better design / note added about custom_error_message
This commit is contained in:
parent
942a47330e
commit
c3733589a3
@ -135,11 +135,10 @@ utility.open = function(file_name, mode, custom_error_message)
|
|||||||
return function(fn)
|
return function(fn)
|
||||||
local success, result_or_error = pcall(function() return fn(file) end)
|
local success, result_or_error = pcall(function() return fn(file) end)
|
||||||
file:close()
|
file:close()
|
||||||
if success then
|
if not success then
|
||||||
return result_or_error
|
error(result_or_error) -- custom_error_message is only for when the file doesn't exist, this function should not hide *your* errors
|
||||||
else
|
|
||||||
error(result_or_error)
|
|
||||||
end
|
end
|
||||||
|
return result_or_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user