mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 22:56:25 +00:00
Added empty json container if server response is empty.
This fixes a possible NullReferenceException, which at least occurred in every call to SaveAlbums().
This commit is contained in:
parent
abc08873a2
commit
c3a63d71e4
@ -37,7 +37,7 @@ namespace SpotifyAPI.Web
|
||||
try
|
||||
{
|
||||
Tuple<ResponseInfo, byte[]> raw = DownloadRaw(url);
|
||||
response = new Tuple<ResponseInfo, string>(raw.Item1, _encoding.GetString(raw.Item2));
|
||||
response = new Tuple<ResponseInfo, string>(raw.Item1, raw.Item2.Length > 0 ? _encoding.GetString(raw.Item2) : "{}");
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
@ -58,7 +58,7 @@ namespace SpotifyAPI.Web
|
||||
try
|
||||
{
|
||||
Tuple<ResponseInfo, byte[]> raw = await DownloadRawAsync(url);
|
||||
response = new Tuple<ResponseInfo, string>(raw.Item1, _encoding.GetString(raw.Item2));
|
||||
response = new Tuple<ResponseInfo, string>(raw.Item1, raw.Item2.Length > 0 ? _encoding.GetString(raw.Item2) : "{}");
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
@ -118,7 +118,7 @@ namespace SpotifyAPI.Web
|
||||
try
|
||||
{
|
||||
Tuple<ResponseInfo, byte[]> data = UploadRaw(url, body, method);
|
||||
response = new Tuple<ResponseInfo, string>(data.Item1, _encoding.GetString(data.Item2));
|
||||
response = new Tuple<ResponseInfo, string>(data.Item1, data.Item2.Length > 0 ? _encoding.GetString(data.Item2) : "{}");
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
@ -139,7 +139,7 @@ namespace SpotifyAPI.Web
|
||||
try
|
||||
{
|
||||
Tuple<ResponseInfo, byte[]> data = await UploadRawAsync(url, body, method);
|
||||
response = new Tuple<ResponseInfo, string>(data.Item1, _encoding.GetString(data.Item2));
|
||||
response = new Tuple<ResponseInfo, string>(data.Item1, data.Item2.Length > 0 ? _encoding.GetString(data.Item2) : "{}");
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user