-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
In openlibraryutility.cs LoadAsync was throwing object null reference on the JToken.Parse(response) line if response was "{}" , note this occurs in my .NET 9 build of OpenLibrary.NET. I added the highlighted line to return null if {} is returned and all seems to work well now. I had the call to GetDataAsync surround with a try catch and I am not sure why the try catch didn't catch the exception.
public async static Task<T?> LoadAsync<T>(HttpClient client, Uri uri, string path = "")
{
string response = await RequestAsync(client, uri);
Debug.WriteLine("LoadAsync:"+response);
if (string.IsNullOrWhiteSpace(path))
return JsonConvert.DeserializeObject<T>(response);
else
{
**_if (response == "{}") return default;_**
JToken token = JToken.Parse(response);
return token[path]!.ToObject<T>();
}
}
Metadata
Metadata
Assignees
Labels
No labels