If this reverse failed, it was throwing a 500.

Catch the 500 in this case and throw a 404 instead.
This commit is contained in:
Feanil Patel
2020-07-08 15:56:53 -04:00
parent 3879ad2252
commit b6fdad2ea4

View File

@@ -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 '#'