title: Which values can DocumentClientException.Error.Code have?
body: <p>I want my data access layer to handle exceptions thrown by DocumentDB API provided via <code>Microsoft.Azure.Documents.Client.DocumentClient</code> class. For example, the optimistic concurrency check implemented using <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.client.accesscondition" rel="nofollow noreferrer">AccessCondition class</a>, but others as well.</p>
  
  <p>By looking at the exception thrown, the best way to recognize different <code>DocumentClient</code>-specific exceptions seems to be something like this:</p>
  
  <pre><code>try { ... }
  catch (DocumentClientException exception) 
      when (exception.Error.Code == "Some magic here")
  {
      //let the user know how to recover from this..
  }
  </code></pre>
  
  <p>I don't like such magic strings as they are not verifiable compile-time. It may contract a typo, or it may change on random moment with DocumentDB client/server changes, etc. Also, it is not clear which such magic codes I could/should be handling since I don't see the <code>Microsoft.Azure.DocumentDB</code> .net API containing any <code>ErrorCodes</code> enum or constants, nor find any list in documentation. </p>
  
  <p><strong>Where can I find a list of possible <code>Error.Code</code> values DocumentClient API can throw?</strong></p>
  
  <p>To make it even more confusing, the XmlDoc for <code>DocumentClient.CreateDocumentAsync</code> method suggest working instead on http status codes.</p>
  
  <p><strong>UPDATE:</strong> This question is not about Http status codes but <code>DocumentClientException.Error.Code</code> field as I assume the latter is more precise.</p>