Use Exceptions for catching DB errors
Merge pull request #3310 from wilsonge/patch-6

[#33474] Use Exceptions for catching DB errors