fix(plugins): catch stop_app exception
This commit is contained in:
parent
f15efb4930
commit
58f32c2572
|
@ -242,7 +242,7 @@ ensure_stopped(NameVsn) ->
|
||||||
tryit("stop_plugin",
|
tryit("stop_plugin",
|
||||||
fun() ->
|
fun() ->
|
||||||
Plugin = do_read_plugin(NameVsn),
|
Plugin = do_read_plugin(NameVsn),
|
||||||
ok = ensure_apps_stopped(Plugin)
|
ensure_apps_stopped(Plugin)
|
||||||
end).
|
end).
|
||||||
|
|
||||||
%% @doc Stop and then start the plugin.
|
%% @doc Stop and then start the plugin.
|
||||||
|
@ -294,16 +294,22 @@ do_ensure_started(NameVsn) ->
|
||||||
|
|
||||||
%% try the function, catch 'throw' exceptions as normal 'error' return
|
%% try the function, catch 'throw' exceptions as normal 'error' return
|
||||||
%% other exceptions with stacktrace returned.
|
%% other exceptions with stacktrace returned.
|
||||||
tryit(What, F) ->
|
tryit(WhichOp, F) ->
|
||||||
try
|
try
|
||||||
F()
|
F()
|
||||||
catch
|
catch
|
||||||
throw : Reason ->
|
throw : Reason ->
|
||||||
|
%% thrown exceptions are known errors
|
||||||
|
%% translate to a return value without stacktrace
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
error : Reason : Stacktrace ->
|
error : Reason : Stacktrace ->
|
||||||
Error = "failed_to_" ++ What,
|
%% unexpected errors, log stacktrace
|
||||||
?SLOG(error, #{msg => Error, exception => Reason, stacktrace => Stacktrace}),
|
?SLOG(warning, #{ msg => "plugin_op_failed"
|
||||||
{error, Error}
|
, which_op => WhichOp
|
||||||
|
, exception => Reason
|
||||||
|
, stacktrace => Stacktrace
|
||||||
|
}),
|
||||||
|
{error, {failed, WhichOp}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% read plugin info from the JSON file
|
%% read plugin info from the JSON file
|
||||||
|
@ -473,7 +479,7 @@ ensure_apps_stopped(#{<<"rel_apps">> := Apps}) ->
|
||||||
{AppName, _AppVsn} = parse_name_vsn(NameVsn),
|
{AppName, _AppVsn} = parse_name_vsn(NameVsn),
|
||||||
AppName
|
AppName
|
||||||
end, Apps),
|
end, Apps),
|
||||||
case stop_apps(AppsToStop) of
|
case tryit("stop_apps", fun() -> stop_apps(AppsToStop) end) of
|
||||||
{ok, []} ->
|
{ok, []} ->
|
||||||
%% all apps stopped
|
%% all apps stopped
|
||||||
ok;
|
ok;
|
||||||
|
|
Loading…
Reference in New Issue