Avoid null reference exception when building Sia error messages.

If the resource does not provide an error response, the Response
property will be null.

This fixes #4193.
This commit is contained in:
Kenneth Hsu
2020-09-27 09:44:50 -07:00
parent 9b977b7ba0
commit 71edf641a5
+5
View File
@@ -83,6 +83,11 @@ namespace Duplicati.Library.Backend.Sia
private string getResponseBodyOnError(string context, System.Net.WebException wex)
{
if (wex.Response is null)
{
return $"{context} failed with error: {wex.Message}";
}
string body = "";
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)wex.Response;
using (System.IO.Stream data = response.GetResponseStream())