diff options
| author | ruki <[email protected]> | 2021-09-25 21:57:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-25 21:57:16 +0800 |
| commit | 697d7cc20e1e2914e72e396cf3158d9893a04e66 (patch) | |
| tree | 37aa610373d521a5768ab53bf8fe8f5bd925724f /xmake/modules/private | |
| parent | 50eeea59ecee08e93e2c69929d12fa6953b92855 (diff) | |
improve error tips for package
Diffstat (limited to 'xmake/modules/private')
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/download.lua | 17 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/install.lua | 11 |
2 files changed, 23 insertions, 5 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index ba918e7f4..63e4c0d80 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -159,7 +159,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- create an empty source directory if do not extract package file os.tryrm(sourcedir) os.mkdir(sourcedir) - raise("cannot extract %s", packagefile) + raise("cannot extract %s, maybe missing extractor or invalid package file!", packagefile) end -- save original file path @@ -230,6 +230,7 @@ function main(package) end -- download url + local allerrors = {} ok = try { function () @@ -248,8 +249,12 @@ function main(package) function (errors) -- show or save the last errors - if errors and (option.get("verbose") or option.get("diagnosis")) then - cprint("${dim color.error}error: ${clear}%s", errors) + if errors then + if (option.get("verbose") or option.get("diagnosis")) then + cprint("${dim color.error}error: ${clear}%s", errors) + else + table.insert(allerrors, errors) + end end -- trace @@ -275,7 +280,11 @@ function main(package) cprint(" ${bright}- %s", table.concat(searchnames:to_array(), ", ")) cprint("and we can run `xmake g --pkg_searchdirs=/xxx` to set the search directories.") end - raise("download failed!") + if #allerrors then + raise(table.concat(allerrors, "\n")) + else + raise("download failed!") + end end end } diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 8e8d92d39..9dcbc537b 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -278,7 +278,16 @@ function main(package) -- failed if not package:requireinfo().optional then if os.isfile(errorfile) then - print("if you want to get verbose errors, please see:") + if errors then + print("") + for idx, line in ipairs(errors:split("\n")) do + print(line) + if idx > 16 then + break + end + end + end + cprint("if you want to get more verbose errors, please see:") cprint(" -> ${bright}%s", errorfile) end raise("install failed!") |
