Opened 5 years ago
Last modified 5 years ago
#30600 closed Cleanup/optimization
Django is silence on ValueError in converter to_python() method. — at Version 1
Reported by: | Fraterius | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | url pattern converter regexp |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Yesterday I've been debugging for few hours my regexp in Converter class which seems to be not working correctly, when the real problem was my Converter's to_python() method which doesn't handle ValueError.
Django instead letting me know where lies the problem simply didn't find matching pattern and returned 404 (so it acted like a regexp problem).
The line responsible for that is:
https://github.com/django/django/blob/26d16c07fdc4a297daca554afa6375c70d6d82a9/django/urls/resolvers.py#L256
I think this should be handled in different manner. At least some note in the documentation letting user know that all ValueError's in Converters method are handled silently (which is somehow not intuitive).