title: Handling OData Error in client
body: <p>I'm consuming a At WebApi 2.2 OData v4 service in a c# client.
  In the server side I'm wrapping exceptions into <code>Microsoft.Odata.Core.ODataError</code> object.</p>
  
  <p>In the Microsoft OData V4 DataServiceClient client and I'm catching the exception in following block of code.</p>
  
  <pre><code>try
  {
      //Post message to server
  }
  catch (DataServiceClientException ex)
  {
      string result = ex.Message;
      ODataError error = JsonConvert.DeserializeObject(result) as ODataError;
  }
  </code></pre>
  
  <p>Here I'm getting null value for <code>error</code> object.
  However the <code>result</code> object has following <code>Json</code> string value.</p>
  
  <pre><code>{
    "error":{
      "code":"Custom Error","message":"The INSERT statement conflicted with the FOREIGN KEY constraint...."
    }
  }
  </code></pre>
  
  <p><strong>Question:</strong>
  How can I convert the <code>Json</code> string to <code>ODataError</code> object?
  My requirement is to read the message property from above <code>Json</code> string like <code>var errmsg = error.message;</code> Is there any alternative?</p>