Better error message for operations on users that don't exist in linkahead_admin.py
Addressed by !153 (merged):
-
Merged
I tried to receive the roles for a user that does not exist and received the following output by linkahead_admin.py:
$ linkahead_admin.py retrieve_user_roles not.existing.user
Traceback (most recent call last):
File "(...)/caosdb-pylib/venv/bin/linkahead_admin.py", line 657, in <module>
sys.exit(main())
^^^^^^
File "(...)/caosdb-pylib/venv/bin/linkahead_admin.py", line 653, in main
return args.call(args)
^^^^^^^^^^^^^^^
File "(...)/caosdb-pylib/venv/bin/linkahead_admin.py", line 196, in do_retrieve_user_roles
print(admin._get_roles(username=args.user_name))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "(...)/caosdb-pylib/src/linkahead/common/administration.py", line 328, in _get_roles
body = con._http_request(method="GET", path="UserRoles/" + (
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "(...)/caosdb-pylib/src/linkahead/connection/connection.py", line 696, in _http_request
return self._retry_http_request(method=method, path=path,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "(...)/caosdb-pylib/src/linkahead/connection/connection.py", line 750, in _retry_http_request
_handle_response_status(http_response)
File "(...)/caosdb-pylib/src/linkahead/connection/connection.py", line 519, in _handle_response_status
raise HTTPResourceNotFoundError("This resource has not been found.")
linkahead.exceptions.HTTPResourceNotFoundError: This resource has not been found.
If you don't know ahead of time what is actually wrong, it's difficult to find out. The user probably has no idea what a "resource" is in this case.
Suggestion for a better error message: "User {username} not found/does not exist."
Edited by Florian Spreckelsen