mirror of
https://github.com/its-michaelroy/Deep-Impact.git
synced 2026-06-03 18:10:42 +00:00
Update utils.py
Fix CodeQL alerts #1 and #2: Secure exception handling in get_sentry and get_quiz 33,115
This commit is contained in:
@@ -28,9 +28,9 @@ def get_sentry():
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
return Response(data, status=HTTP_200_OK)
|
||||
except ValidationError as e:
|
||||
print(e)
|
||||
return Response(e, status=HTTP_400_BAD_REQUEST)
|
||||
except (requests.RequestException, json.JSONDecodeError) as e:
|
||||
logger.error(f"Error in get_sentry: {str(e)}", exc_info=True)
|
||||
return Response({"error": "Failed to fetch Sentry data"}, status=HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
|
||||
@@ -110,9 +110,9 @@ def get_quiz():
|
||||
print(data)
|
||||
|
||||
return Response(data, status=HTTP_201_CREATED)
|
||||
except ValidationError as e:
|
||||
print(e)
|
||||
return Response(e, status=HTTP_400_BAD_REQUEST)
|
||||
except (json.JSONDecodeError, openai.OpenAIError) as e:
|
||||
logger.error(f"Error in get_quiz: {str(e)}", exc_info=True)
|
||||
return Response({"error": "Failed to generate quiz"}, status=HTTP_400_BAD_REQUEST)
|
||||
|
||||
# ask_question()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user