Added basic error handling for database issues.