Skip to content

Improve auth response error handling #74

Description

@jordanyordanov

Hi @anthonyreilly

Occasionally I receive the below error when the auth response received from Salesforce is an html page instead of a json result. Possibly during Salesforce maintenance downtime. I would like to be able to customize the response deserialization and possibly extract more information from the html page in order to provide a more meaningful message instead of the below error.
I already sent you one pull request that would allow me to inject the deserialization logic and improve the error handling. Could you please kindly review it? Alternatively, if you could add exception handling that would put the html content in the exception message that would be great.

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at NetCoreForce.Client.AuthenticationClient.<UsernamePasswordAsync>d__18.MoveNext()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions