Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#8265 closed (duplicate)

Debug template exception message is confuse

Reported by: marinho Owned by: nobody
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When some error happens and the debug page for error 500 is shown with debug informations, the exception value is shown as a H2 element, like this:

Caught an exception while rendering: The 'image' attribute has no file associated with it. Original Traceback (most recent call last): File "../django/django/template/debug.py", line 71, in render_node result = node.render(context) File "../django/django/template/defaulttags.py", line 148, in render nodelist.append(node.render(context)) File "../django/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "../django/django/template/__init__.py", line 518, in resolve obj = self.var.resolve(context) File "../django/django/template/__init__.py", line 659, in resolve value = self._resolve_lookup(context) File "../django/django/template/__init__.py", line 688, in _resolve_lookup current = getattr(current, bit) File "/arquivos/Trabalhos/WN/Cranes/cranes_com/apps/spares/models.py", line 108, in __getattr__ thumbnail = get_image_thumbnail_filename() File "/arquivos/Trabalhos/WN/Cranes/cranes_com/apps/spares/models.py", line 100, in get_image_thumbnail_filename file, ext = os.path.splitext(self.image.path) File "../django/django/db/models/fields/files.py", line 50, in _get_path self._require_file() File "../django/django/db/models/fields/files.py", line 40, in _require_file raise ValueError("The '%s' attribute has no file associated with it." % self.field.name) ValueError: The 'image' attribute has no file associated with it. 

This is VERY confuse and make developer spent some time to find the error message and the file/line where the error occured.

My suggestion is change the H2 tag to PRE, with some CSS changes, so, the line breaks are respected exactly as they are when Python raises the exception.

Attachments (1)

8265.diff (753 bytes) - added by marinho 7 years ago.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by marinho

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This is basically the same as #8178.

comment:2 Changed 7 years ago by anonymous

  • milestone 1.0 maybe deleted

Milestone 1.0 maybe deleted

Note: See TracTickets for help on using tickets.
Back to Top