From af3bf3c51cb8a72c568c4b70f930010ea5f4dd29 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 28 Nov 2007 19:17:13 +0000 Subject: [PATCH] Improving error reporting and completing 1.0.2. --- NEWS | 4 ++++ controller/Expose.py | 8 ++++++-- controller/Notebooks.py | 2 +- controller/Root.py | 9 ++++++++- controller/Users.py | 2 +- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 10798a1..b399042 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +1.0.2: November 28, 2007 + * Refactored code that creates note summaries for the link info box. + * Improved error reporting when a loading a page that causes an exception. + 1.0.1: November 17, 2007 * Ability to create, rename, delete, and switch between multiple wiki notebooks in a single account. diff --git a/controller/Expose.py b/controller/Expose.py index ec1f0c3..66f7d6a 100644 --- a/controller/Expose.py +++ b/controller/Expose.py @@ -47,11 +47,13 @@ def expose( view = None, rss = None ): kwargs = dict( [ ( str( key ), value ) for ( key, value ) in kwargs.items() ] ) # try executing the exposed function + original_error = None try: result = function( *args, **kwargs ) except cherrypy.NotFound: raise except Exception, error: + original_error = error if hasattr( error, "to_dict" ): result = error.to_dict() else: @@ -74,8 +76,10 @@ def expose( view = None, rss = None ): return unicode( view_override( **result ) ) except: if redirect is None: - print result - raise + if original_error: + raise original_error + else: + raise # if that doesn't work, and there's a redirect, then redirect del( result[ u"redirect" ] ) diff --git a/controller/Notebooks.py b/controller/Notebooks.py index a07a62a..d9803c5 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -18,7 +18,7 @@ from view.Html_file import Html_file class Access_error( Exception ): def __init__( self, message = None ): if message is None: - message = u"Sorry, you don't have access to do that." + message = u"Sorry, you don't have access to do that. Please make sure you're logged in first." Exception.__init__( self, message ) self.__message = message diff --git a/controller/Root.py b/controller/Root.py index 5eb5c21..3c90a12 100644 --- a/controller/Root.py +++ b/controller/Root.py @@ -219,7 +219,14 @@ class Root( object ): traceback.print_exc() self.report_traceback() - cherrypy.response.body = [ unicode( Error_page( support_email ) ) ] + import sys + error = sys.exc_info()[ 1 ] + if hasattr( error, "to_dict" ): + error_message = error.to_dict().get( u"error" ) + else: + error_message = None + + cherrypy.response.body = [ unicode( Error_page( support_email, message = error_message ) ) ] def report_traceback( self ): """ diff --git a/controller/Users.py b/controller/Users.py index 62062b0..95a75aa 100644 --- a/controller/Users.py +++ b/controller/Users.py @@ -372,7 +372,7 @@ class Users( object ): user = anonymous if not user or not anonymous: - raise Access_error( u"Sorry, you don't have access to do that." ) + raise Access_error( u"Sorry, you don't have access to do that. Please make sure you're logged in first." ) # in addition to this user's own notebooks, add to that list the anonymous user's notebooks login_url = None