title: How To Parse ODATA Error
body: <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt;
      &lt;m:code /&gt;
      &lt;m:message xml:lang="en-US"&gt;An error occurred while processing this request.&lt;/m:message&gt;
      &lt;m:innererror&gt;
          &lt;m:message&gt;Exception has been thrown by the target of an invocation.&lt;/m:message&gt;
          &lt;m:type&gt;System.Reflection.TargetInvocationException&lt;/m:type&gt;
          &lt;m:stacktrace&gt;&lt;/m:stacktrace&gt;
          &lt;m:internalexception&gt;
              &lt;m:message&gt;An error occurred while executing the command definition. See the inner exception for details.&lt;/m:message&gt;
              &lt;m:type&gt;System.Data.Entity.Core.EntityCommandExecutionException&lt;/m:type&gt;
              &lt;m:stacktrace&gt;&lt;/m:stacktrace&gt;
              &lt;m:internalexception&gt;
                  &lt;m:message&gt;Cannot insert duplicate key row in object 'XXXX' with unique index 'XXXXXX'. The duplicate key value is (XXXXX)&lt;/m:message&gt;
                  &lt;m:type&gt;System.Data.SqlClient.SqlException&lt;/m:type&gt;
                  &lt;m:stacktrace&gt;&lt;/m:stacktrace&gt;
              &lt;/m:internalexception&gt;
          &lt;/m:internalexception&gt;
      &lt;/m:innererror&gt;
  &lt;/m:error&gt;" System.Data.Services.Client.DataServiceClientException
  </code></pre>
  
  <p>I have this XML structure coming back from a WEB API 2 ODATA source. I need to parse this error at the server then pass a new error to the client.I have tried deserializing this to various Exception types, but the fact that Exception Implement IDICTIONARY stops that. How can I deserialize this into a strongly typed object? </p>
  
  <p>If the above isn't easily down, I guess my other question would be <code>what is best practice for handling these errors</code></p>