Better exception throwing logic for search commands