fix: log error when failed to install plugin

the error return is a map with details.
prior to this change only the reason is returned in the api response,
now the error map is logged at error level to help troubleshooting
This commit is contained in:
Zaiming (Stone) Shi 2023-11-30 16:49:30 +01:00
parent eed253af82
commit 5427ebc5f1
2 changed files with 4 additions and 3 deletions

View File

@ -399,7 +399,7 @@ do_install_package(FileName, Bin) ->
end,
{400, #{
code => 'BAD_PLUGIN_INFO',
message => iolist_to_binary([Reason, ":", FileName])
message => iolist_to_binary([Reason, ": ", FileName])
}}
end.
@ -445,7 +445,8 @@ install_package(FileName, Bin) ->
case emqx_plugins:ensure_installed(PackageName) of
{error, #{return := not_found}} = NotFound ->
NotFound;
{error, _Reason} = Error ->
{error, Reason} = Error ->
?SLOG(error, Reason#{msg => "failed_to_install_plugin"}),
_ = file:delete(File),
Error;
Result ->

View File

@ -83,7 +83,7 @@
describe(NameVsn) -> read_plugin(NameVsn, #{fill_readme => true}).
%% @doc Install a .tar.gz package placed in install_dir.
-spec ensure_installed(name_vsn()) -> ok | {error, any()}.
-spec ensure_installed(name_vsn()) -> ok | {error, map()}.
ensure_installed(NameVsn) ->
case read_plugin(NameVsn, #{}) of
{ok, _} ->