diff options
| author | ruki <[email protected]> | 2019-07-22 13:56:04 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-22 13:56:04 +0800 |
| commit | 4fafbae0430e7f9b4a85d280d6fb0efbd2cf35b5 (patch) | |
| tree | 5d37ad16fcdd6db1c7fa4b2080d20643673439fa /xmake/core/base | |
| parent | de065e129a52e21b96104c897216d8b2b77afba6 (diff) | |
| parent | 145358ba831e7a90f275118a0556787754fe2fa6 (diff) | |
Merge pull request #503 from OpportunityLiu/dev
Improve error messge
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/os.lua | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 2f17ebc27..b8d767efd 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -706,7 +706,10 @@ end -- -- the parent function will capture it if we uses pcall or xpcall -- -function os.raise(msg, ...) +function os.raiselevel(level, msg, ...) + + -- set level of this function + level = level + 1 -- flush log log:flush() @@ -716,19 +719,28 @@ function os.raise(msg, ...) -- raise it if type(msg) == "string" then - error(string.tryformat(msg, ...)) + error(string.tryformat(msg, ...), level) elseif type(msg) == "table" then local errobjstr, errors = string.serialize(msg, true) if errobjstr then - error("[@encode(error)]: " .. errobjstr) + error("[@encode(error)]: " .. errobjstr, level) else - error(errors) + error(errors, level) end else - error() + error(tostring(msg), level) end end +-- raise an exception and abort the current script +-- +-- the parent function will capture it if we uses pcall or xpcall +-- +function os.raise(msg, ...) + -- add return to make it a tail call + return os.raiselevel(1, msg, ...) +end + -- is executable program file? function os.isexec(filepath) |
