Added caller in to the exception message

Added caller in to the exception message to debug ENT-1849
Replaced `get_enterprise_learner_data` method call with `enterprise_customer_for_request` to get enterprise customer data from cache or session instead of hitting API.
This commit is contained in:
Zia Fazal
2019-11-11 19:44:24 +05:00
parent b845fae0bc
commit 5b6e0514de
2 changed files with 6 additions and 4 deletions

View File

@@ -40,8 +40,8 @@ class ContactUsView(View):
if request.user.is_authenticated:
context['course_id'] = request.session.get('course_id', '')
context['user_enrollments'] = CourseEnrollment.enrollments_for_user_with_overviews_preload(request.user)
enterprise_learner_data = enterprise_api.get_enterprise_learner_data(user=request.user)
if enterprise_learner_data:
enterprise_customer = enterprise_api.enterprise_customer_for_request(request)
if enterprise_customer:
tags.append('enterprise_learner')
context['tags'] = tags

View File

@@ -5,6 +5,7 @@ from __future__ import absolute_import
import logging
from functools import wraps
import traceback
from django.conf import settings
from django.contrib.auth.models import User
@@ -256,9 +257,10 @@ class EnterpriseApiClient(object):
response = endpoint().get(**querystring)
except (HttpClientError, HttpServerError):
LOGGER.exception(
u'Failed to get enterprise-learner for user [%s] with client user [%s]',
u'Failed to get enterprise-learner for user [%s] with client user [%s]. Caller: %s',
user.username,
self.user.username
self.user.username,
"".join(traceback.format_stack())
)
return None