Validate categories and handle errors