rundb: Capture and report db errors more helpfully.

This should go part of the way to solving the database integrity error raised by #920.

The rundb cursor should now behave as follows:
 * attempt to run db operation
 * if a failure arises as a result of a integrity error and that error is due to an insert, report that and "correct" the operation to an insert or replace

Exceptions raised now report the db operation(s) and arguments that were being carried out at the time of the error.

This will not resolve the underlying problem in #920 but should prevent it killing a suite and provide more useful error messages for helping identify what's going wrong.