Add error handling for database failure.