Skip to content

Commit

Permalink
refactor: log exception
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Dec 5, 2024
1 parent d8e4718 commit 00defae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions courses/views/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Course views verson 1"""

import logging

from django.db.models import Prefetch, Q
from mitol.digitalcredentials.mixins import DigitalCredentialsRequestViewSetMixin
from rest_framework import status, viewsets
Expand Down Expand Up @@ -30,6 +32,8 @@
from courses.sync_external_courses.emeritus_api import fetch_emeritus_courses
from ecommerce.models import Product

log = logging.getLogger(__name__)


class ProgramViewSet(viewsets.ReadOnlyModelViewSet):
"""API view set for Programs"""
Expand Down Expand Up @@ -219,8 +223,9 @@ def get(self, request, *args, **kwargs): # noqa: ARG002
try:
data = fetch_emeritus_courses()
return Response(data, status=status.HTTP_200_OK)
except Exception as e: # noqa: BLE001
except Exception:
log.exception("Some error occurred fetching Emeritus courses")
return Response(
{"error": str(e)},
{"error": "Some error occurred."},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)

0 comments on commit 00defae

Please sign in to comment.