调用CreateDocumentAsync()时,是否需要检查ResourceResponse是否有错误?例如,有一个.StatusCode属性。
或者try-catch会处理所有可能的错误情况?
尝试捕捉就是这样,
try
{
//Get a Document client
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
{
RunDemoAsync(databaseId, CollectionId).Wait();
}
}
catch (DocumentClientException de)
{
Exception baseException = de.GetBaseException();
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
}
catch (Exception e)
{
Exception baseException = e.GetBaseException();
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
}
finally
{
Console.WriteLine("End of demo, press any key to exit.");
Console.ReadKey();
}