<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code />
<m:message xml:lang="en-US">An error occurred while processing this request.</m:message>
<m:innererror>
<m:message>Exception has been thrown by the target of an invocation.</m:message>
<m:type>System.Reflection.TargetInvocationException</m:type>
<m:stacktrace></m:stacktrace>
<m:internalexception>
<m:message>An error occurred while executing the command definition. See the inner exception for details.</m:message>
<m:type>System.Data.Entity.Core.EntityCommandExecutionException</m:type>
<m:stacktrace></m:stacktrace>
<m:internalexception>
<m:message>Cannot insert duplicate key row in object 'XXXX' with unique index 'XXXXXX'. The duplicate key value is (XXXXX)</m:message>
<m:type>System.Data.SqlClient.SqlException</m:type>
<m:stacktrace></m:stacktrace>
</m:internalexception>
</m:internalexception>
</m:innererror>
</m:error>" System.Data.Services.Client.DataServiceClientException
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?
If the above isn't easily down, I guess my other question would be what is best practice for handling these errors