Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions openedx/core/djangoapps/user_api/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from drf_yasg.utils import swagger_auto_schema
from edx_ace import ace
from edx_ace.recipient import Recipient
from edx_django_utils.monitoring import record_exception
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomerUser, PendingEnterpriseCustomerUser
Expand Down Expand Up @@ -1107,10 +1108,32 @@ def post(self, request):
user=retirement.user,
)
except UserRetirementStatus.DoesNotExist:
log.error(
'UserRetirementStatus not found for retirement action'
)
record_exception()
return Response(status=status.HTTP_404_NOT_FOUND)
except RetirementStateError as exc:
try:
user_id = retirement.user.id
except AttributeError:
user_id = 'unknown'
log.error(
'RetirementStateError during user retirement: user_id=%s, error=%s',
user_id, str(exc)
)
record_exception()
return Response(str(exc), status=status.HTTP_400_BAD_REQUEST)
except Exception as exc: # pylint: disable=broad-except
try:
user_id = retirement.user.id
except AttributeError:
user_id = 'unknown'
log.error(
'Unexpected error during user retirement: user_id=%s, error=%s',
user_id, str(exc)
)
record_exception()
return Response(str(exc), status=status.HTTP_500_INTERNAL_SERVER_ERROR)

return Response(status=status.HTTP_204_NO_CONTENT)
Expand Down
Loading