From d9ad26b4ec066a1062553a32555039131fd824f7 Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 25 Mar 2015 13:56:42 +0100 Subject: [PATCH] If command crashes, return restuple with error and explanation (ejabberd-contrib #21) --- src/ejabberd_commands.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ejabberd_commands.erl b/src/ejabberd_commands.erl index c279f2d0f..a4f38e836 100644 --- a/src/ejabberd_commands.erl +++ b/src/ejabberd_commands.erl @@ -317,7 +317,13 @@ execute_command2(Command, Arguments) -> Module = Command#ejabberd_commands.module, Function = Command#ejabberd_commands.function, ?DEBUG("Executing command ~p:~p with Args=~p", [Module, Function, Arguments]), - apply(Module, Function, Arguments). + try apply(Module, Function, Arguments) of + Response -> + Response + catch + Problem -> + {error, Problem} + end. -spec get_tags_commands() -> [{string(), [string()]}].