Improved API for wrapping database errors.

Thanks Alex Gaynor for the proposal.