Opened 4 years ago

Closed 2 years ago

#16227 closed New feature (wontfix)

Include traceback in a comment when hitting an exception in debug mode

Reported by: Odd_Bloke Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords:
Cc: djangoproject.com@…, Odd_Bloke, anton@…, philipkimmey, oliver@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

As discussed on the mailing list, debugging can be a real pain using curl or when dealing with AJAX, as one has to manually parse the HTML.

It would be better if the traceback could be provided in an HTML comment near the top of the file, as this will not impact the normal display at all, but make debugging in these cases a vastly more pleasant experience.

Attachments (1)

traceback-in-comment.patch (2.2 KB) - added by Odd_Bloke 4 years ago.

Download all attachments as: .zip

Change History (14)

Changed 4 years ago by Odd_Bloke

comment:1 Changed 4 years ago by haras

  • Cc djangoproject.com@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:3 Changed 4 years ago by Odd_Bloke

  • Cc Odd_Bloke added

comment:4 Changed 4 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Design decision needed
  • UI/UX set

comment:5 Changed 4 years ago by zuko

  • Cc anton@… added

comment:6 Changed 4 years ago by julien

  • Type changed from Uncategorized to New feature

comment:7 Changed 4 years ago by philipkimmey

I've been thinking about this one quite a bit, and my suspicion is the most common inconvenience is seeing the full HTML dump when making AJAX requests.

I'm curious how commonly people are using curl (or similar methods).

At least personally, maybe 35% of the time I see an error message it's in Chrome's debug console.

My personal preference would be to simply have massively simplified templates (e.g. not HTML) for the common case of AJAX requests. We could have inline TECHNICAL_AJAX_*_TEMPLATE or something along those lines. Then we can just use request.is_ajax() to choose the template.

Although it doesn't resolve the case of using curl, if AJAX is the common case, I think it would be worth the minor increase in complexity.

If there is interest in something along these lines, I would be happy to contribute a patch.

comment:8 Changed 4 years ago by philipkimmey

  • Cc philipkimmey added

comment:9 Changed 4 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #10841.

comment:10 Changed 4 years ago by obeattie

  • Cc oliver@… added
  • Resolution duplicate deleted
  • Status changed from closed to reopened

I'm reopening this as I think the scope of this is different to #10841.

While that helps a great deal for debugging AJAX requests, it still doesn't cover the case where the requests aren't AJAX, but your client is still not a browser; for instance, when debugging a REST API (when you're almost certainly going to be using command-line tools to test things).

I think it's be very helpful to include a standard-format traceback at the bottom of the document in a HTML comment; it would make debugging vastly easier. For what it's worth, this is something other frameworks are already doing (Flask springs to mind). Given how simple this is to implement, and in view that it wouldn't have any chance of introducing problems – there is already a standard-format traceback in the copy-and-paste view half way up the page after all – I think it's a total no-brainer.

comment:11 Changed 4 years ago by aaugustin

  • Component changed from Uncategorized to Core (Other)

comment:12 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:13 Changed 2 years ago by apollo13

  • Resolution set to wontfix
  • Status changed from new to closed

I think we don't need a feature like this, with the LOGGING framework you can easily add a console handler to 'django.request' and get a trace in the runserver console.

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