fix: load bad configs return unknown msg
This commit is contained in:
parent
b4cffc581b
commit
8aab919f74
|
@ -237,6 +237,12 @@ load_config(Bin, Opts) when is_binary(Bin) ->
|
||||||
case hocon:binary(Bin) of
|
case hocon:binary(Bin) of
|
||||||
{ok, RawConf} ->
|
{ok, RawConf} ->
|
||||||
load_config_from_raw(RawConf, Opts);
|
load_config_from_raw(RawConf, Opts);
|
||||||
|
%% Type is scan_error, parse_error...
|
||||||
|
{error, {Type, Meta = #{reason := Reason}}} ->
|
||||||
|
{error, Meta#{
|
||||||
|
reason => unicode:characters_to_binary(Reason),
|
||||||
|
type => Type
|
||||||
|
}};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -364,10 +364,10 @@ configs(get, #{query_string := QueryStr, headers := Headers}, _Req) ->
|
||||||
{error, _} = Error -> {400, #{code => 'INVALID_ACCEPT', message => ?ERR_MSG(Error)}}
|
{error, _} = Error -> {400, #{code => 'INVALID_ACCEPT', message => ?ERR_MSG(Error)}}
|
||||||
end;
|
end;
|
||||||
configs(put, #{body := Conf, query_string := #{<<"mode">> := Mode} = QS}, _Req) ->
|
configs(put, #{body := Conf, query_string := #{<<"mode">> := Mode} = QS}, _Req) ->
|
||||||
IngnoreReadonly = maps:get(<<"ignore_readonly">>, QS, false),
|
IgnoreReadonly = maps:get(<<"ignore_readonly">>, QS, false),
|
||||||
case
|
case
|
||||||
emqx_conf_cli:load_config(Conf, #{
|
emqx_conf_cli:load_config(Conf, #{
|
||||||
mode => Mode, log => none, ignore_readonly => IngnoreReadonly
|
mode => Mode, log => none, ignore_readonly => IgnoreReadonly
|
||||||
})
|
})
|
||||||
of
|
of
|
||||||
ok ->
|
ok ->
|
||||||
|
|
Loading…
Reference in New Issue