From 99929c461e8e05c941a9b2ca6ebc9c5fea8f98e0 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 15 Sep 2002 23:06:20 +0000 Subject: [PATCH] nicer error message for invalid class lookup git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1169 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/back_anydbm.py | 7 +++++-- roundup/backends/back_gadfly.py | 7 +++++-- roundup/backends/back_metakit.py | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index f36213d..91f8a76 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.78 2002-09-13 08:20:07 richard Exp $ +#$Id: back_anydbm.py,v 1.79 2002-09-15 23:06:20 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -121,7 +121,10 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): ''' if __debug__: print >>hyperdb.DEBUG, 'getclass', (self, classname) - return self.classes[classname] + try: + return self.classes[classname] + except KeyError: + raise KeyError, 'There is no class called "%s"'%classname # # Class DBs diff --git a/roundup/backends/back_gadfly.py b/roundup/backends/back_gadfly.py index b6579bf..225f341 100644 --- a/roundup/backends/back_gadfly.py +++ b/roundup/backends/back_gadfly.py @@ -1,4 +1,4 @@ -# $Id: back_gadfly.py,v 1.19 2002-09-13 08:20:13 richard Exp $ +# $Id: back_gadfly.py,v 1.20 2002-09-15 23:06:20 richard Exp $ __doc__ = ''' About Gadfly ============ @@ -356,7 +356,10 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): ''' if __debug__: print >>hyperdb.DEBUG, 'getclass', (self, classname) - return self.classes[classname] + try: + return self.classes[classname] + except KeyError: + raise KeyError, 'There is no class called "%s"'%classname def clear(self): ''' Delete all database contents. diff --git a/roundup/backends/back_metakit.py b/roundup/backends/back_metakit.py index c7592a4..43a5223 100755 --- a/roundup/backends/back_metakit.py +++ b/roundup/backends/back_metakit.py @@ -57,7 +57,10 @@ class _Database(hyperdb.Database): return self.dirty return self.getclass(classname) def getclass(self, classname): - return self.classes[classname] + try: + return self.classes[classname] + except KeyError: + raise KeyError, 'There is no class called "%s"'%classname def getclasses(self): return self.classes.keys() # --- end of ping's spec -- 2.30.2