|
|
@@ -423,13 +423,21 @@ param_path_id() ->
|
|
|
%% Internal functions
|
|
|
%%------------------------------------------------------------------------------
|
|
|
|
|
|
-err_msg({RuleError, {_E, R, _S}}) when is_tuple(R) ->
|
|
|
- emqx_misc:readable_error_msg(emqx_json:encode([{RuleError, element(1, R)}]));
|
|
|
-err_msg({RuleError, {_E, R, _S}}) ->
|
|
|
- emqx_misc:readable_error_msg(emqx_json:encode([{RuleError, R}]));
|
|
|
+err_msg({RuleError, {_E, Reason, _S}}) ->
|
|
|
+ emqx_misc:readable_error_msg(encode_nested_error(RuleError, Reason));
|
|
|
err_msg(Msg) ->
|
|
|
emqx_misc:readable_error_msg(Msg).
|
|
|
|
|
|
+encode_nested_error(RuleError, Reason) when is_tuple(Reason) ->
|
|
|
+ encode_nested_error(RuleError, element(1, Reason));
|
|
|
+encode_nested_error(RuleError, Reason) ->
|
|
|
+ case emqx_json:safe_encode([{RuleError, Reason}]) of
|
|
|
+ {ok, Json} ->
|
|
|
+ Json;
|
|
|
+ _ ->
|
|
|
+ {RuleError, Reason}
|
|
|
+ end.
|
|
|
+
|
|
|
format_rule_resp(Rules) when is_list(Rules) ->
|
|
|
[format_rule_resp(R) || R <- Rules];
|
|
|
format_rule_resp({Id, Rule}) ->
|