mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-02-05 07:45:18 -05:00
feat: Implement centralized error capture and handling with new middleware, services, and API endpoints, and add new admin and statistics API views.
This commit is contained in:
@@ -38,6 +38,7 @@ from ..serializers.maps import (
|
||||
MapLocationsResponseSerializer,
|
||||
MapSearchResponseSerializer,
|
||||
)
|
||||
from apps.core.utils import capture_and_log
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -332,7 +333,7 @@ class MapLocationsAPIView(APIView):
|
||||
return Response(result)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapLocationsAPIView: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Get map locations', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Failed to retrieve map locations"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -489,7 +490,7 @@ class MapLocationDetailAPIView(APIView):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapLocationDetailAPIView: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Get map location detail', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Failed to retrieve location details"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -674,7 +675,7 @@ class MapSearchAPIView(APIView):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapSearchAPIView: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Map search', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Search failed due to internal error"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -851,7 +852,7 @@ class MapBoundsAPIView(APIView):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapBoundsAPIView: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Get map bounds', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Failed to retrieve locations within bounds"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -904,7 +905,7 @@ class MapStatsAPIView(APIView):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapStatsAPIView: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Get map stats', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Failed to retrieve map statistics"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -956,7 +957,7 @@ class MapCacheAPIView(APIView):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapCacheAPIView.delete: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Clear map cache', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Failed to clear map cache"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
@@ -984,7 +985,7 @@ class MapCacheAPIView(APIView):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapCacheAPIView.post: {str(e)}", exc_info=True)
|
||||
capture_and_log(e, 'Invalidate map cache', source='api')
|
||||
return Response(
|
||||
{"status": "error", "detail": "Failed to invalidate cache"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user