Added exception handling and input validation in ShoppingCart