Fix error handling in WhoAmI data view

This commit is contained in:
Finn Stutzenstein 2020-11-30 13:00:03 +01:00
parent c323eabd6f
commit e1183fff60
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
2 changed files with 4 additions and 3 deletions

View File

@ -36,6 +36,7 @@ from ..utils.auth import (
from ..utils.autoupdate import AutoupdateElement, inform_changed_data, inform_elements
from ..utils.cache import element_cache
from ..utils.rest_api import (
APIException,
ModelViewSet,
Response,
SimpleMetadata,
@ -858,9 +859,8 @@ class WhoAmIDataView(APIView):
self.request.user.get_collection_string(), user_id
)
if user_full_data is None:
return Response(
{"detail": "Cache offline, could not fetch user"}, status=500
)
raise APIException(f"Could not find user {user_id}", 500)
auth_type = user_full_data["auth_type"]
user_data = async_to_sync(element_cache.restrict_element_data)(
user_full_data, self.request.user.get_collection_string(), user_id

View File

@ -51,6 +51,7 @@ from .cache import element_cache
__all__ = [
"APIException",
"detail_route",
"DecimalField",
"list_route",