diff --git a/course_discovery/apps/edx_elasticsearch_dsl_extensions/viewsets.py b/course_discovery/apps/edx_elasticsearch_dsl_extensions/viewsets.py index c1fee89883..9904462ce5 100644 --- a/course_discovery/apps/edx_elasticsearch_dsl_extensions/viewsets.py +++ b/course_discovery/apps/edx_elasticsearch_dsl_extensions/viewsets.py @@ -117,8 +117,8 @@ def paginate_queryset(self, queryset, request, view=None): if search_after: try: queryset = queryset.extra(search_after=json.loads(search_after)) - except json.JSONDecodeError: - raise ValueError("Invalid JSON format for search_after parameter") + except json.JSONDecodeError as exc: + raise ValueError("Invalid JSON format for search_after parameter") from exc queryset = super().paginate_queryset(queryset, request, view)