Opened 18 years ago
Closed 13 years ago
#6170 closed Bug (fixed)
Reverse urlresolver raises obscure exceptions on failure
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Core (Other) | Version: | dev |
| Severity: | Normal | Keywords: | reverse urls exception 'unbalanced parenthesis' |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Related to ticket #2977.
When reverse fails to reverse a complex regex obscure errors can be raised. For instance, reversing the url r'^(\d(\d)?)/$' causes an 'unbalanced parenthesis' to be raised from re.py._compile.
The urlresolver is clearly in flux right now; however, this error could be very difficult for someone new to Django (read, me) to understand. Better exception catching that notifies when a url isn't supported by reverse would be very helpful.
Attachments (2)
Change History (10)
by , 18 years ago
| Attachment: | core_urlresovlers__better_error_message.diff added |
|---|
comment:1 by , 18 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
I have never participated in a bug tracker before, but if it weren't for this ticket, I never would have figured out what was wrong. I vote for the new code to be added. It would have pointed me to the right place to fix my problem immediately.
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:4 by , 15 years ago
| Easy pickings: | unset |
|---|---|
| Needs tests: | set |
by , 13 years ago
comment:6 by , 13 years ago
| Needs tests: | unset |
|---|
The original patch no longer made sense, so I wrote a new one and added a test. ImproperlyConfigured is probably a more descriptive exception for this issue than NoReverseMatch.
comment:7 by , 13 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:8 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
I wrote a small patch to give a better error message. I remember, that I had this problem some time ago, too.