Hello! On Thu, Jul 27, 2006 at 08:39:02PM +0300, Dan Pascu wrote: > Following the discussion we had about 2 months ago about having sqlobject > raise a set of exceptions independent of the backend used, I asked a > colleague of mine to implement this. > He did it for the mysql and sqlite backends
This is a good start, thank you! > ---------- Forwarded Message ---------- > Subject: Database exceptions handling > Date: Wednesday 26 July 2006 08:03 > From: Mircea Amarascu <[EMAIL PROTECTED]> > To: sqlobject-discuss@lists.sourceforge.net > > I've discovered that the Database API Specification v2.0 is followed by > both MySQL and > SQLite Python modules, so all that need to be done in this case was a > one-to-one mapping between > their exceptions and the SQLObject defined ones. I am not so sure about one-to-one mapping. On a duplicate inserts Some DB drivers raise ProgrammingError, some raise OperationError, some IntegrityError. This is what we'd like to unify in a consistent set of SQLObject's exceptions. > Index: sqlite/sqliteconnection.py > =================================================================== > > +class ErrorMessage(str): > + def __new__(cls, e): > + obj = str.__new__(cls, e[0]) > + obj.code = None > + obj.module = e.__module__ > + obj.exception = e.__class__.__name__ > + return obj > + These classes are too similar. Are they really two different classes? > Index: mysql/mysqlconnection.py > =================================================================== > > +class ErrorMessage(str): > + def __new__(cls, e): > + obj = str.__new__(cls, e[1]) > + obj.code = int(e[0]) > + obj.module = e.__module__ > + obj.exception = e.__class__.__name__ > + return obj > + Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss