Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.

Changes between Version 2 and Version 4 of Ticket #7985


Ignore:
Timestamp:
02/08/12 16:57:17 (12 years ago)
Author:
wmoore
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7985

    • Property Status changed from new to accepted
  • Ticket #7985 – Description

    v2 v4  
    4545 
    4646== Custom Error handling == 
    47 If you want to handle certain exceptions in particular ways, E.g. display a particular message to the user, log particular details etc, 
     47If you want to handle certain exceptions in particular ways  
    4848you should use appropriate try/except statements. 
    49 For more info on logging, see [link] 
    5049 
    51 This is only advised for trivial errors, where you can give the user a simple message, E.g."No Objects selected, Please try again". 
     50This is only advised for trivial errors, where you can give the user a simple message, E.g."No Objects selected, Please try again", or if the error is well understood and you can recover from the error in a reasonable way.  
    5251 
    53 For server errors, it is usually best to allow the exception to be handled by Django since this will provide a lot more info to the user (request details etc) 
     52For 'unexpected' server errors, it is best to allow the exception to be handled by Django since this will provide a lot more info to the user (request details etc) 
    5453and format html etc (both with Debug True or False).  
    55 If you still want to handle the exception yourself, you can provide stack trace alongside a message for the user. 
     54 
     55If you still want to handle the exception yourself, you can provide stack trace alongside a message for the user. If the request is ajax, don't return html, since the response text will be displayed in a dialog box for the user (not rendered as html).  
    5656 
    5757{{{ 
     
    6969 
    7070 
    71 An alternative is to raise the exception with your custom message, allowing Django to handle it: 
    72  
    73 {{{ 
    74  
    75 except Exception, x: 
    76     logger.error(traceback.format_exc())                                    # log the stack trace 
    77     err_msg = "Something bad happened! \n \n%s" % traceback.format_exc() 
    78     raise x.__class__(err_msg) 
    79 }}} 
    80  
    81 However, the stack trace of the Exception will originate from your raise statement, even though the message of the exception 
    82 contains your original stack trace. 
    83  
     71== 404 Errors == 
     72For unknown IDs (Object not found) try to return that message in the 404 message. 

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.13731 sec.)

We're Hiring!