Django

Code

Ticket #8178 (closed: fixed)

Opened 4 months ago

Last modified 3 months ago

Insert linebreaks in debug summary

Reported by: julien Assigned to: nobody
Milestone: 1.0 Component: Uncategorized
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

When exceptions are raised, in particular in templates (e.g. with URL tag not matching a view), you get a big chunk of traceback info in the debug summary which is hard to read. Inserting linebreaks helps a lot. Patch attached.

Before:

Caught an exception while rendering: Original Traceback (most recent call last): File "E:\Software\workspace\django\django\template\debug.py", line 71, in render_node result = node.render(context) File "E:\Software\workspace\django-treemenus\trunk\treemenus\templatetags\tree_menu_tags.py", line 46, in render return urlNode.render(context) File "E:\Software\workspace\django\django\template\defaulttags.py", line 369, in render args=args, kwargs=kwargs) File "E:\Software\workspace\django\django\core\urlresolvers.py", line 307, in reverse *args, **kwargs))) File "E:\Software\workspace\django\django\core\urlresolvers.py", line 291, in reverse raise NoReverseMatch NoReverseMatch 

After:

Caught an exception while rendering:

Original Traceback (most recent call last):
File "E:\Software\workspace\django\django\template\debug.py", line 71, in render_node
result = node.render(context)
File "E:\Software\workspace\django-treemenus\trunk\treemenus\templatetags\tree_menu_tags.py", line 46, in render
return urlNode.render(context)
File "E:\Software\workspace\django\django\template\defaulttags.py", line 369, in render
args=args, kwargs=kwargs)
File "E:\Software\workspace\django\django\core\urlresolvers.py", line 307, in reverse
*args, **kwargs)))
File "E:\Software\workspace\django\django\core\urlresolvers.py", line 291, in reverse
raise NoReverseMatch
NoReverseMatch

Attachments

8178.linebreaks.diff (483 bytes) - added by julien on 08/08/08 21:48:14.
8178.stylefix.diff (0.6 kB) - added by julien on 08/24/08 21:57:08.
The error message should not have a sans-serif font.

Change History

08/08/08 21:48:14 changed by julien

  • attachment 8178.linebreaks.diff added.

08/12/08 05:48:57 changed by julianb

  • needs_better_patch changed.
  • needs_docs changed.
  • stage changed from Unreviewed to Ready for checkin.
  • needs_tests changed.
  • milestone set to 1.0 beta.

08/12/08 08:29:53 changed by julien

  • milestone changed from 1.0 beta to 1.0.

This is only a small improvement and that doesn't quite fit in the 1.0 beta milestone.

08/12/08 10:29:06 changed by julianb

Yes, sorry, but it's so tiny it should be in 1.0 nonetheless.

(follow-up: ↓ 5 ) 08/12/08 15:56:02 changed by marinho

Why not show the exception message as PRE instead of H2 in template?

In my opinion would be better, because the formatting (including spaces) would be respected and be better as look :)

I created a ticket similar to this (I didn't know about this), take a look on that: #8265

(in reply to: ↑ 4 ) 08/12/08 19:50:31 changed by julien

Replying to marinho:

Why not show the exception message as PRE instead of H2 in template? In my opinion would be better, because the formatting (including spaces) would be respected and be better as look :)

Marinho, you're making a good point. The patch you've submitted in #8265 is indeed much better, and it should be used instead of the one I've submitted here.

08/16/08 07:33:36 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [8407]) Fixed #8178: Cleaned up the rendering of exceptions on the error template. Thanks to Marinho Brandão for the fix.

08/16/08 10:46:00 changed by julianb

You forgot to do the same where it says "Exception value". Here the fix:

Index: django/views/debug.py
===================================================================
--- django/views/debug.py	(revision 8409)
+++ django/views/debug.py	(working copy)
@@ -405,7 +405,7 @@
     </tr>
     <tr>
       <th>Exception Value:</th>
-      <td>{{ exception_value|escape }}</td>
+      <td><pre>{{ exception_value|escape }}</pre></td>
     </tr>
     <tr>
       <th>Exception Location:</th>

08/16/08 10:55:56 changed by mtredinnick

  • status changed from closed to reopened.
  • resolution deleted.

Not reopening the ticket won't help the oversight get fixed.

08/16/08 23:28:36 changed by russellm

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [8420]) Fixed #8178: Another update to debug template to aid rendering of exception traces. Thanks to julianb for the report.

08/24/08 21:56:25 changed by julien

  • status changed from closed to reopened.
  • resolution deleted.

Sorry to re-re-open this, but Marinho's patch hadn't been applied correctly. The error message should not have a sans-serif font. Patch attached.

08/24/08 21:57:08 changed by julien

  • attachment 8178.stylefix.diff added.

The error message should not have a sans-serif font.

08/24/08 22:31:45 changed by russellm

  • status changed from reopened to closed.
  • resolution set to fixed.

Is your complaint about the serifs, or using a non-monospaced font? Using Helvetica/Arial family (non-monospaced, sans serif) was a conscious decision, because a big block of large, seriffed, monospaced text looks awful, and I couldn't see any loss in usability for the text that is returned.

08/24/08 23:01:46 changed by julien

Thanks Russell for the info, and sorry for the noise. I wasn't sure if it was a mistake or a deliberate choice. Your reasons for keeping Helvetica/Arial totally make sense and I'm fine with it ;)


Add/Change #8178 (Insert linebreaks in debug summary)




Change Properties
Action