diff options
| author | William Boman <william@redwill.se> | 2023-03-05 03:21:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-05 02:21:54 +0000 |
| commit | 35e33e4b6df6130a79fa91ee2dd7e1318be8dc88 (patch) | |
| tree | 988c9126fd7fd0a4e0443fd01e0e5a8c53c4f6d4 /lua/mason-core | |
| parent | refactor(package): lazy-require modules (#1060) (diff) | |
| download | mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.tar mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.tar.gz mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.tar.bz2 mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.tar.lz mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.tar.xz mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.tar.zst mason-35e33e4b6df6130a79fa91ee2dd7e1318be8dc88.zip | |
fix(package): emit registry event on abnormal failures (#1061)
Also display a more helpful error message in the UI, as well as terminating the handle if it's not yet terminated.
Diffstat (limited to 'lua/mason-core')
| -rw-r--r-- | lua/mason-core/package/init.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lua/mason-core/package/init.lua b/lua/mason-core/package/init.lua index 5060ff5c..88e89c41 100644 --- a/lua/mason-core/package/init.lua +++ b/lua/mason-core/package/init.lua @@ -108,8 +108,19 @@ function Package:install(opts) ---@param result Result function(success, result) if not success then + -- Installer failed abnormally (i.e. unexpected exception in the installer code itself). log.error("Unexpected error", result) + handle.stdio.sink.stderr(tostring(result)) + handle.stdio.sink.stderr "\nInstallation failed abnormally. Please report this error." self:emit("install:failed", handle) + registry:emit("package:install:failed", self, handle) + + -- We terminate _after_ emitting failure events because [termination -> failed] have different + -- meaning than [failed -> terminate] ([termination -> failed] is interpreted as a triggered + -- termination). + if not handle:is_closed() and not handle.is_terminated then + handle:terminate() + end return end result |
