From eee98a5803b45d2db372ee8b2fcf0417d7fe8489 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Thu, 5 Aug 2021 09:25:49 +0800 Subject: [PATCH] fix(API): return 400 if delete failed --- apps/emqx_management/src/emqx_mgmt_api_configs.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_api_configs.erl b/apps/emqx_management/src/emqx_mgmt_api_configs.erl index 1d1a9e0b6..b69593747 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_configs.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_configs.erl @@ -40,6 +40,8 @@ } }). +-define(ERR_MSG(MSG), io_lib:format("~p", [MSG])). + api_spec() -> {config_apis(), []}. @@ -92,8 +94,11 @@ config(get, Req) -> config(delete, Req) -> %% TODO: remove the config specified by the query string param 'conf_path' - emqx_config:remove(conf_path_from_querystr(Req)), - {200}; + case emqx_config:remove(conf_path_from_querystr(Req)) of + ok -> {200}; + {error, Reason} -> + {400, ?ERR_MSG(Reason)} + end; config(put, Req) -> Path = [binary_to_atom(Key, latin1) || Key <- conf_path_from_querystr(Req)],