Ticket #6170: core_urlresovlers__better_error_message.diff

File core_urlresovlers__better_error_message.diff, 970 bytes (added by Thomas Güttler, 17 years ago)
  • django/core/urlresolvers.py

     
    125125            test_regex = grouped
    126126        # Note we're using re.match here on purpose because the start of
    127127        # to string needs to match.
    128         if not re.match(test_regex + '$', force_unicode(value), re.UNICODE):
    129             raise NoReverseMatch("Value %r didn't match regular expression %r" % (value, test_regex))
     128        try:
     129            if not re.match(test_regex + '$', force_unicode(value), re.UNICODE):
     130                raise NoReverseMatch("Value %r didn't match regular expression %r" % (value, test_regex))
     131        except re.error:
     132            raise NoReverseMatch("Failed to reverse regular expression. Does it contain nested parenthesis?")
     133           
    130134        return force_unicode(value)
    131135
    132136class RegexURLPattern(object):
Back to Top