From 447f70d17a7e1633e842b29d22750c09f75fdae2 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Thu, 2 Oct 2025 13:19:21 +0300 Subject: [PATCH] Fixes: 1) Handle generic Exception in `current` method of viewsets to prevent 500 errors; Extra: 1) Add fallback error response with status 400 for unexpected exceptions. --- core/viewsets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/viewsets.py b/core/viewsets.py index 78b91faa..ae737b05 100644 --- a/core/viewsets.py +++ b/core/viewsets.py @@ -840,6 +840,8 @@ class OrderViewSet(EvibesViewSet): except Order.DoesNotExist: name = "Order" return Response(status=status.HTTP_404_NOT_FOUND, data={"detail": _(f"{name} does not exist: {uuid}")}) + except Exception as e: + return Response(status=status.HTTP_400_BAD_REQUEST, data={"detail": str(e)}) @action(detail=False, methods=["post"], url_path="buy_unregistered") @method_decorator(ratelimit(key="ip", rate="10/h" if not settings.DEBUG else "888/h"))