diff options
| -rw-r--r-- | xmake/core/base/utils.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index 5b0c68a5e..584af7eb7 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -234,19 +234,34 @@ function utils.trycall(script, traceback, ...) if errors then local _, pos = errors:find("[@encode(error)]: ", 1, true) if pos then + -- strip traceback (maybe from coroutine.resume) local errs = errors:sub(pos + 1) + local stack = nil + local stackpos = errs:find("}\nstack traceback:", 1, true) + if stackpos and stackpos > 1 then + stack = errs:sub(stackpos + 2) + errs = errs:sub(1, stackpos) + end errors, errs = errs:deserialize() if not errors then errors = errs end if type(errors) == "table" then + if stack then + errors._stack = stack + end setmetatable(errors, { __tostring = function (self) - if self.errors then - return self.errors + local result = self.errors + if not result then + result = string.serialize(self, {strip = true, indent = false}) + end + result = result or "" + if self._stack then + result = result .. "\n" .. self._stack end - return string.serialize(self) + return result end, __concat = function (self, other) return tostring(self) .. tostring(other) |
