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.
This commit is contained in:
parent
4bce9224fc
commit
447f70d17a
1 changed files with 2 additions and 0 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue