Skip to content

Commit

Permalink
Fix issue where full error is exposed to external users (#914)
Browse files Browse the repository at this point in the history
Signed-off-by: Tmpecho <[email protected]>
  • Loading branch information
Tmpecho authored Oct 28, 2024
1 parent 07a2ab5 commit ef656d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 6 additions & 5 deletions app/career/views/weekly_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class WeeklyBusinessViewSet(BaseViewSet):

queryset = WeeklyBusiness.objects.none()
serializer_class = WeeklyBusinessSerializer
permission_classes = [BasicViewPermission]
Expand Down Expand Up @@ -57,9 +56,10 @@ def create(self, request, *args, **kwargs):
return Response(
{"detail": serializer.errors}, status=status.HTTP_400_BAD_REQUEST
)
except ValueError as value_error:
except ValueError:
return Response(
{"detail": str(value_error)}, status=status.HTTP_400_BAD_REQUEST
{"detail": "En feil oppstod under behandlingen av forespørselen."},
status=status.HTTP_400_BAD_REQUEST
)

def update(self, request, pk):
Expand All @@ -78,9 +78,10 @@ def update(self, request, pk):
return Response(
{"detail": serializer.errors}, status=status.HTTP_400_BAD_REQUEST
)
except ValueError as value_error:
except ValueError:
return Response(
{"detail": str(value_error)}, status=status.HTTP_400_BAD_REQUEST
{"detail": "En feil oppstod under behandlingen av forespørselen."},
status=status.HTTP_400_BAD_REQUEST
)

def destroy(self, request, *args, **kwargs):
Expand Down
14 changes: 6 additions & 8 deletions app/content/views/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ def upload(request):
{"url": url},
status=status.HTTP_200_OK,
)

except ValueError as value_error:
except ValueError:
return Response(
{"detail": str(value_error)},
status=status.HTTP_400_BAD_REQUEST,
{"detail": "En feil oppstod under behandlingen av forespørselen."},
status=status.HTTP_400_BAD_REQUEST
)


Expand All @@ -54,9 +53,8 @@ def delete(request, container_name, blob_name):
{"detail": "Filen ble slettet"},
status=status.HTTP_200_OK,
)

except ValueError as value_error:
except ValueError:
return Response(
{"detail": str(value_error)},
status=status.HTTP_400_BAD_REQUEST,
{"detail": "En feil oppstod under behandlingen av forespørselen."},
status=status.HTTP_400_BAD_REQUEST
)

0 comments on commit ef656d3

Please sign in to comment.