Better error handling for the profile command