Refactored error handling for GetComponents method