witten
/
luminotes
Archived
1
0
Fork 0

Improving error reporting and completing 1.0.2.

This commit is contained in:
Dan Helfman 2007-11-28 19:17:13 +00:00
parent 0152b49475
commit af3bf3c51c
5 changed files with 20 additions and 5 deletions

4
NEWS
View File

@ -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.

View File

@ -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" ] )

View File

@ -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

View File

@ -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 ):
"""

View File

@ -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