From b6fdad2ea4a4ff820d6d67cc62eb93a3fa42c9f4 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 8 Jul 2020 15:56:53 -0400 Subject: [PATCH] If this reverse failed, it was throwing a 500. Catch the 500 in this case and throw a 404 instead. --- common/djangoapps/edxmako/shortcuts.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/edxmako/shortcuts.py b/common/djangoapps/edxmako/shortcuts.py index 6c1160ae4c..08a7c6c98c 100644 --- a/common/djangoapps/edxmako/shortcuts.py +++ b/common/djangoapps/edxmako/shortcuts.py @@ -17,9 +17,9 @@ import logging import six from django.conf import settings -from django.http import HttpResponse +from django.http import Http404, HttpResponse from django.template import engines -from django.urls import reverse +from django.urls import reverse, NoReverseMatch from six.moves.urllib.parse import urljoin from django.core.validators import URLValidator from django.core.exceptions import ValidationError @@ -90,7 +90,10 @@ def marketing_link(name): if all([host_name and 'edge' in host_name, 'http' in link_map[name]]): return link_map[name] else: - return reverse(link_map[name]) + try: + return reverse(link_map[name]) + except NoReverseMatch: + raise Http404 else: log.debug(u"Cannot find corresponding link for name: %s", name) return '#'