handle errors
This commit is contained in:
@@ -9,6 +9,7 @@ from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
||||
# Create your views here.
|
||||
from rest_framework import status
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.permissions import IsAuthenticatedOrReadOnly, IsAdminUser, IsAuthenticated
|
||||
@@ -127,7 +128,7 @@ def load_coop_products(request):
|
||||
logging.error(f"Could not parse {row}")
|
||||
return Response()
|
||||
except Exception as e:
|
||||
return Response({"errors": {"details": str(type(e))}})
|
||||
return Response({"errors": {"details": str(type(e))}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
@api_view(['GET',]) # include allowed methods
|
||||
@@ -168,4 +169,4 @@ def product_search(request):
|
||||
product_serializer = ProductSerializer(result_set, many=True)
|
||||
return Response(data={"filters": filters, "products": product_serializer.data})
|
||||
except Exception as e:
|
||||
return Response({"errors": {"details": str(type(e))}})
|
||||
return Response({"errors": {"details": str(type(e))}}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
Reference in New Issue
Block a user