I added StatementError after having too often a custom type or other kind of error happen deep inside the preparation for execution with no indication what statement or parameter caused the issue. It's an enhancement, and the original exception is associated with the new one as "orig". In Python 3 this works even more nicely as you can see we're doing "raise x from e", and you get both stacktraces. What about the StatementError is not working for you ? I'd advise against doing things like business-level validations in types.
On Jun 21, 2011, at 6:39 PM, [email protected] wrote: > Hi, > > I'm porting sqlamp [1] to SQLAlchemy 0.7 and have some difficulties > with it. One of them is raising an exception (non-DBAPI) from > process_bind_param() method of classes derived from TypeDecorator. In > 0.6 [2] method _handle_dbapi_exception() of engine.base.Connectable > doesn't munch the exception if it is not an instance of > self.dialect.dbapi.Error. 0.7 in turn does [3]. And it reraises the > exception of different type - instead of the original one it uses > DBAPIError.instance(), which in my case returns StatementError. How > can I fix it on my side? > > Thanks. > > -- > Anton > > [1] http://sqlamp.angri.ru > [2] > http://www.sqlalchemy.org/trac/browser/lib/sqlalchemy/engine/base.py?rev=7667%3A6bf675d91a56#L1321 > [3] > http://www.sqlalchemy.org/trac/browser/lib/sqlalchemy/engine/base.py?rev=7665%3A145c143cef74#L1685 > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
