From 7328ad929bab08778b1e4c9c82c0e20934f62510 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 30 Nov 2023 15:16:54 -0500 Subject: Added in better error handling. --- src/lpm.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lpm.lua b/src/lpm.lua index 23ad06d..e122fe9 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -464,7 +464,7 @@ function common.chdir(dir, callback) system.chdir(dir) local status, err = pcall(callback) system.chdir(wd) - if not status then error(err) end + if not status then error(err, 0) end end function common.stat(path) local stat = system.stat(path) @@ -536,7 +536,8 @@ end local status = 0 local function error_handler(err) - local s, e = err and err:find(":%d+") + local s, e + if err then s, e = err:find("%:%d+") end local message = e and err:sub(e + 3) or err if JSON then if VERBOSE then @@ -892,7 +893,7 @@ function Addon:install(bottle, installing) bottle:invalidate_cache() if not status then common.rmrf(temporary_install_path) - error(err) + error(err, 0) elseif self.type ~= "meta" then if POST and self.post then common.chdir(temporary_install_path, function() @@ -1202,7 +1203,7 @@ function Repository:fetch() local dir = common.dirname(path) if system.stat(dir) and #system.ls(dir) == 0 then common.rmrf(dir) end end - error(err) + error(err, 0) end return self end -- cgit v1.2.3