anthonyreilly / NetCoreForce

Salesforce REST API toolkit for .NET Standard and .NET Core
MIT License
110 stars 63 forks source link

Request: Extend ErrorResponse model #63

Closed asleire closed 3 months ago

asleire commented 1 year ago

The current ErrorResponse model contains a limited number of properties and is specifically missing the duplicateResut property (no - not a typo)

Since there are likely to be a number of other possible error properties I'd like it if a "catch-all" dictionary property was added to include any unknown properties. This can be achieved using the Newtonsoft.Json JsonExtensionDataAttribute, e.g. by extending the model like this:

  public class ErrorResponse
  {
    /// <summary>Fields related to the error</summary>
    [JsonProperty(PropertyName = "fields")]
    public List<string> Fields { get; set; }

    /// <summary>Error message</summary>
    [JsonProperty(PropertyName = "message")]
    public string Message { get; set; }

    /// <summary>Error code</summary>
    [JsonProperty(PropertyName = "errorCode")]
    public string ErrorCode { get; set; }

    /// <summary>Additional error data</summary>
    [JsonExtensionData]
    public Dictionary<string, JToken> AdditionalData { get; set; }
  }