public async Task Troubleshooting() { await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this); SearchIndexClient client = resources.GetQueryClient(); LookupHotel(); // We want the sample to have a return but the unit test doesn't // like that so we move it into a block scoped function Response <Hotel> LookupHotel() { #region Snippet:Azure_Search_Tests_Samples_Readme_Troubleshooting try { return(client.GetDocument <Hotel>("12345")); } catch (RequestFailedException ex) when(ex.Status == 404) { Console.WriteLine("We couldn't find the hotel you are looking for!"); Console.WriteLine("Please try selecting another."); return(null); } #endregion Snippet:Azure_Search_Tests_Samples_Readme_Troubleshooting } }