Add database errors to error constants

closes #826