correcting error handling with old code side where db errors occur and cause internal server errors.