#22412: Clarify expectation around template filters and exceptions --------------------------------------+------------------------------------ Reporter: carljm | Owner: nobody Type: Cleanup/optimization | Status: new Component: Documentation | Version: 1.6 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------------+------------------------------------
Comment (by carljm): On further thought, I do recognize that there is a difference with template tags and filters; generally speaking they have no Python caller whom one can expect to handle some exceptions; most exceptions coming from a template tag/filter will result in a 500 server error. So that does call for more caution in raising exceptions, but I still think "never raise exceptions" is the wrong advice: if your template filter gets input that clearly represents a bug in a template which should be fixed, raising an exception may still be a better choice than failing silently. Here is my proposed wording, which I will commit if it gets a +1: {{{ Usually any exception raised from a template filter will be exposed as a server error, so filter functions should attempt to return something, and should avoid raising exceptions if there is a reasonable fallback value to return. In case of input that clearly represents a bug in the template, raising an exception may still be better than silent failure which hides the bug. }}} -- Ticket URL: <https://code.djangoproject.com/ticket/22412#comment:4> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.57815bf12b32f94df2804d1f58072912%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.