From 7e4012bf09c53089a0fbc88f0852df1399cf4f90 Mon Sep 17 00:00:00 2001 From: Timur Date: Sat, 1 Mar 2025 23:24:48 +0300 Subject: [PATCH] add handler on `user not found` exception --- services/backend/api/v1/auth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/backend/api/v1/auth.py b/services/backend/api/v1/auth.py index 1d36ce9..4284e49 100644 --- a/services/backend/api/v1/auth.py +++ b/services/backend/api/v1/auth.py @@ -19,7 +19,10 @@ class BearerAuth(HttpBearer): except Exception: raise AuthenticationError - user = User.objects.get(id=data["id"]) + try: + user = User.objects.get(id=data["id"]) + except User.DoesNotExist: + raise AuthenticationError return user @staticmethod