Skip to content

Commit

Permalink
Sending errors from the microservices on to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehewitt15 committed Jul 26, 2023
1 parent 83fce47 commit 8e4e403
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/oceandbs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.views.decorators.csrf import csrf_exempt
from django.http import JsonResponse

from rest_framework import serializers, parsers
from rest_framework.views import APIView
Expand Down Expand Up @@ -278,7 +279,12 @@ def post(self, request):
else:
return Response(serializer.errors, status=400)
else:
return Response({'error': 'Storage service response badly formatted.'}, status=400)
try:
return Response(response, status=400)
except Exception as e:
return JsonResponse({'error': f'An unexpected error occurred: {str(e)}'}, status=500)



# Quote detail endpoint displaying the detail of a quote, no update, no deletion for now.
class QuoteStatusView(APIView):
Expand Down

0 comments on commit 8e4e403

Please sign in to comment.