Better error handling for search