Merge pull request #12735 from zhongwencool/fix-ban-crash

fix: don't crash when ban ip error
This commit is contained in:
JianBo He 2024-03-19 20:57:54 +08:00 committed by GitHub
commit c7db157ecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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} ->