Open Guacam-Ole opened 1 year ago
very simple suggestion to change this:
private static T TryDeserialize<T>(string json)
{
if (json[0] == '{')
{
var error = JsonConvert.DeserializeObject<Error>(json);
if (error != null && !string.IsNullOrEmpty(error.Description))
{
throw new ServerErrorException(error);
}
}
try
{
return JsonConvert.DeserializeObject<T>(json)!;
}
catch (Exception ex)
{
ex.Data.Add("json", json);
ex.Data.Add("type", typeof(T));
throw;
}
}
Any objections against this? I assume this should not be too much overhead also don't expect that the json contains secrets. But I am open for discussion
I have a workaround with custom derived type (you can do proper logging there, I'm simply tracking the last message for my particular scenario).
I constantly receive errors like this:
This is not an error of MastoNet but either of the API or simply my media (most likely). Nonetheless: The error message
Unexpected character encountered while parsing value: <. Path
does not really help me there. I assume instead of the expected response the API returns an error message that cannot be parsed into the expected objecttype.Can we change the behaviour to have the original error response inside the Exception instead of the resulting Deserialization-Error?