Implement new exception interception and filtering layer

Replace @_wrap_db_error() with an event-based system
that leverages the new SQLAlchemy handle_error() event.

The internal logic of @_wrap_db_error() is replaced by a
system of declarative filters, which is also expressed
on the testing side using a new test framework for these
conditions.

partially implement bp: use-events-for-error-wrapping
Closes-Bug: #1214341
Change-Id: Ib8c7f8d5c6f44c49a53dd6411adbf8aaaecb74be
Merge "Implement new exception interception and filtering layer"