fauna / faunadb-csharp

C# driver for FaunaDB v4

Home Page:https://fauna.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle ResponseContent is not JSON

ptpaterson opened this issue · comments

If a non 2XX error code is received, then resultRequest.ResponseContent is deserialized by Newtonsoft.Json.

var wrapper = JsonConvert.DeserializeObject<ErrorsWrapper>(resultRequest.ResponseContent);

However, the ResponseContent received is sometimes not JSON. One user received the following error; it's possible that the ResponseContent is html rather than a JSON string.

Error :Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

It may be helpful to handle this error more gracefully and provide the user with a better message.