Commits

Mike Bayer committed f0235df

DB connection errors wrapped in DBAPIErrors

Comments (0)

Files changed (3)

 - fixed up Boolean datatype
 - added count()/count_by() to list of methods proxied by assignmapper;
 this also adds them to activemapper
+- connection exceptions wrapped in DBAPIError
 
 0.2.5
 - fixed endless loop bug in select_by(), if the traversal hit

lib/sqlalchemy/engine/default.py

             dbapi = dialect.dbapi()
             if dbapi is None:
                 raise exceptions.InvalidRequestError("Cant get DBAPI module for dialect '%s'" % dialect)
-            self._pool = poolclass(lambda: dbapi.connect(*cargs, **cparams), **kwargs)
+            def connect():
+                try:
+                    return dbapi.connect(*cargs, **cparams)
+                except Exception, e:
+                    raise exceptions.DBAPIError("Connection failed", e)
+            self._pool = poolclass(connect, **kwargs)
         else:
             if isinstance(pool, sqlalchemy.pool.DBProxy):
                 self._pool = pool.get_pool(*cargs, **cparams)

lib/sqlalchemy/exceptions.py

     
 class DBAPIError(SQLAlchemyError):
     """something weird happened with a particular DBAPI version"""
-    pass
+    def __init__(self, message, orig):
+        SQLAlchemyError.__init__(self, "(%s) (%s) %s"% (message, orig.__class__.__name__, str(orig)))
+        self.orig = orig