summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Klishin <michael@clojurewerkz.org>2020-06-04 05:51:10 +0300
committerMichael Klishin <michael@clojurewerkz.org>2020-06-04 05:51:10 +0300
commita13b62ce620793fba849dc66177d34c68bab606e (patch)
tree83c1b9ef265cf59001f6ead739d713eb3e05cb99 /src
parentdb1e15071c3781b6baa2db9adce00142abffa263 (diff)
downloadrabbitmq-server-git-a13b62ce620793fba849dc66177d34c68bab606e.tar.gz
Improve reporting of 'ctl set_user_tags' failures
Part of rabbitmq/rabbitmq-server#2363
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_auth_backend_internal.erl28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/rabbit_auth_backend_internal.erl b/src/rabbit_auth_backend_internal.erl
index c878c0cb78..31d1fd2a9a 100644
--- a/src/rabbit_auth_backend_internal.erl
+++ b/src/rabbit_auth_backend_internal.erl
@@ -348,14 +348,26 @@ change_password_hash(Username, PasswordHash, HashingAlgorithm) ->
set_tags(Username, Tags, ActingUser) ->
ConvertedTags = [rabbit_data_coercion:to_atom(I) || I <- Tags],
- rabbit_log:info("Setting user tags for user '~s' to ~p~n",
- [Username, ConvertedTags]),
- R = update_user(Username, fun(User) ->
- User#internal_user{tags = ConvertedTags}
- end),
- rabbit_event:notify(user_tags_set, [{name, Username}, {tags, ConvertedTags},
- {user_who_performed_action, ActingUser}]),
- R.
+ rabbit_log:debug("Asked to set user tags for user '~s' to ~p", [Username, ConvertedTags]),
+ try
+ R = update_user(Username, fun(User) ->
+ User#internal_user{tags = ConvertedTags}
+ end),
+ rabbit_log:info("Successfully set user tags for user '~s' to ~p", [Username, ConvertedTags]),
+ rabbit_event:notify(user_tags_set, [{name, Username}, {tags, ConvertedTags},
+ {user_who_performed_action, ActingUser}]),
+ R
+ catch
+ throw:{error, {no_such_user, _}} = Error ->
+ rabbit_log:warning("Failed to set tags for user '~s': the user does not exist", [Username]),
+ throw(Error);
+ throw:Error ->
+ rabbit_log:warning("Failed to set tags for user '~s': ~p", [Username, Error]),
+ throw(Error);
+ exit:Error ->
+ rabbit_log:warning("Failed to set tags for user '~s': ~p", [Username, Error]),
+ exit(Error)
+ end .
-spec set_permissions
(rabbit_types:username(), rabbit_types:vhost(), regexp(), regexp(),