From c3733589a392020bd46aacc94d1364adf40ce251 Mon Sep 17 00:00:00 2001 From: Tangent Date: Sat, 9 Nov 2024 00:51:44 -0700 Subject: [PATCH] better design / note added about custom_error_message --- utility-functions.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utility-functions.lua b/utility-functions.lua index 4cf292a..3499d38 100644 --- a/utility-functions.lua +++ b/utility-functions.lua @@ -135,11 +135,10 @@ utility.open = function(file_name, mode, custom_error_message) return function(fn) local success, result_or_error = pcall(function() return fn(file) end) file:close() - if success then - return result_or_error - else - error(result_or_error) + if not success then + error(result_or_error) -- custom_error_message is only for when the file doesn't exist, this function should not hide *your* errors end + return result_or_error end end