fix: don't crash when ban ip error

This commit is contained in:
zhongwencool 2024-03-19 19:10:36 +08:00
parent 8227e567a1
commit 111cbbbe3c
1 changed files with 2 additions and 1 deletions

View File

@ -169,7 +169,8 @@ banned(get, #{query_string := Params}) ->
banned(post, #{body := Body}) ->
case emqx_banned:parse(Body) of
{error, Reason} ->
{400, 'BAD_REQUEST', list_to_binary(Reason)};
ErrorReason = io_lib:format("~p", [Reason]),
{400, 'BAD_REQUEST', list_to_binary(ErrorReason)};
Ban ->
case emqx_banned:create(Ban) of
{ok, Banned} ->