Skip to content

Commit 6c751b0

Browse files
committed
ejabberd_commands: Show meaningul error message when problem executing command (#4506)
1 parent 0e8e457 commit 6c751b0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ejabberd_commands.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,17 @@ do_execute_command(Command, Arguments) ->
321321
Function = Command#ejabberd_commands.function,
322322
?DEBUG("Executing command ~p:~p with Args=~p", [Module, Function, Arguments]),
323323
ejabberd_hooks:run(api_call, [Module, Function, Arguments]),
324-
apply(Module, Function, Arguments).
324+
try apply(Module, Function, Arguments)
325+
catch
326+
throw:Term ->
327+
?ERROR_MSG("A problem appears when executing command ~p with arguments ~p:~n ~p:~p",
328+
[Command#ejabberd_commands.name, Arguments, throw, Term]),
329+
throw(Term);
330+
exit:Reason ->
331+
?ERROR_MSG("A problem appears when executing command ~p with arguments ~p:~n ~p:~p",
332+
[Command#ejabberd_commands.name, Arguments, exit, Reason]),
333+
error(Reason)
334+
end.
325335

326336
-spec get_tags_commands() -> [{string(), [string()]}].
327337

0 commit comments

Comments
 (0)