Changes between Version 1 and Version 2 of Ticket #25369


Ignore:
Timestamp:
Sep 8, 2015, 5:06:32 PM (9 years ago)
Author:
Paul Graham
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25369 – Description

    v1 v2  
    2727
    2828
    29 In the '''A complex example''' ( [https://docs.djangoproject.com/en/1.8/ref/contrib/syndication/#a-complex-example] ) example code the method {{{get_object()}}} uses {{{get_object_or_404()}}} to raise an {{{Http404}}} exception (See A. above).  However the the Feed class reference on the same page indicates that {{{ObjectDoesNotExist}}} exception should be raised on error below looking at the code of the {{{__call__()}}} method of the Feed class shows that it calls the {{{get_object()}}} method it does indeed catch {{{ObjectDoesNotExist}}} exceptions (See B. above). However, the reason the example code runs without any obvious errors and the root of the problem at hand is that upon catching an ObjectDoesNotExist exception the Feed class then raises an {{{Http404}}} error. The {{{Http404}}} exception being raised in the example code for {{{get_object()}}} is not being caught where it should be, inside {{{Feed.__call__()}}}  but ultimately farther up the chain by the code that was meant to catch errors from {{{Feed.__call__()}}}
     29In the '''A complex example''' ( [https://docs.djangoproject.com/en/1.8/ref/contrib/syndication/#a-complex-example] ) example code the method {{{get_object()}}} uses {{{get_object_or_404()}}} to raise an {{{Http404}}} exception (See A. above).  However the the Feed class reference on the same page indicates that {{{ObjectDoesNotExist}}} exception should be raised on error. Looking at the code of the {{{__call__()}}} method of the Feed class shows that it calls the {{{get_object()}}} method and it does indeed catch {{{ObjectDoesNotExist}}} exceptions (See B. above). However, the reason the example code runs without any obvious errors and the root of the problem at hand is that upon catching an ObjectDoesNotExist exception the Feed class then raises an {{{Http404}}} error. This means that the {{{Http404}}} exception being raised in the example code for {{{get_object()}}} is not being caught where it should be, inside {{{Feed.__call__()}}}  but ultimately falls through that try: except: block and is handled farther up the chain by the code that was meant to catch errors from {{{Feed.__call__()}}}
    3030
    3131
Back to Top