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 Initial Version and Version 1 of Ticket #7985


Ignore:
Timestamp:
02/03/12 16:11:31 (12 years ago)
Author:
wmoore
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7985 – Description

    initial v1  
    99This content can be added below for now - move to trac wiki later. 
    1010 
     11 
     12 
     13== OMERO.web error Handling == 
     14 
     15Django comes with some nice error handling functionality. We have customised this and 
     16also provided some client-side error handling in Javascript to deal with errors in AJAX requests.  
     17This javascript can be found in the ..?...js code which should be included in all pages that require this functionality.  
     18Errors are handled as follows: 
     19 - 404 Simply display a 404 message to the user 
     20 - 403 This is 'permission denied' which probably means the user needs to login to the server (E.g. session may have timed out). The page is refreshed which will redirect the user to login page. 
     21 - 500 Server error. We display a feedback form for the user to submit details of the error to our QA system - POSTs to "qa.openmicroscopy.org.uk:80". This url is configurable in settings.py. 
     22 
     23 
     24There are various scenarios for handling errors, depending on whether you handle them yourself, or allow Django to handle them,  
     25whether you are in Debug mode or not, and whether the http request is AJAX. 
     26 
     27 
     28== Default behavior == 
     29If you do not write any error handling (or if the error occurs outside a try/except block etc... 
     30 
     31=== With Debug: True (during development) === 
     32 
     33Django will return an html page describing the error, with various parameters, stack trace etc.  
     34If the request was AJAX, and you have our javascript code on your page then the error will be handled as described (see above). 
     35NB: With Debug True, 500 errors will be returned as html pages by Django but these will not be rendered as html in our feedback form. 
     36You can use developer tools on your browser (E.g. Firebug on Firefox) to see various errors and open the request in a new tab 
     37to display the full debug info as html.  
     38 
     39=== With Debug: False (in production) === 
     40Django will use it's internal error handling to produce standard 404, 500 error pages. We have customised  
     41this behaviour to display our own error pages. The 500 error page allows you to submit the error as  
     42feedback to our QA system. If the request is AJAX, we return the stack trace is displayed in a dialog 
     43which also allows the error to be submitted to QA. 
     44 
     45 
     46== Custom Error handling == 
     47If you want to handle certain exceptions in particular ways, E.g. display a particular message to the user, log particular details etc, 
     48you should use appropriate try/except statements. 
     49For more info on logging, see [link] 
     50For 500 errors, it is a good idea to always return the stack trace along with any message you want the user to see. 
     51This allows users to inspect or submit the error for diagnosis etc.  
     52{{{ 
     53try: 
     54    # something bad happens 
     55except: 
     56    logger.error(traceback.format_exc())                                    # log the stack trace 
     57    err_msg = "Something bad happened! \n \n%s" % traceback.format_exc()    # message AND stack trace 
     58    return HttpResponseServerError(err_msg) 
     59}}} 
     60 
     61 

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

We're Hiring!