mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-17 12:15:47 +02:00
Improve logged error message when update checking fails
This commit is contained in:
parent
738557b3a2
commit
cfedb7d6b1
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web.Script.Serialization;
|
using System.Web.Script.Serialization;
|
||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
@ -28,7 +30,7 @@ public Task<UpdateInfo> Check(){
|
|||||||
result.SetCanceled();
|
result.SetCanceled();
|
||||||
}
|
}
|
||||||
else if (task.IsFaulted){
|
else if (task.IsFaulted){
|
||||||
result.SetException(task.Exception.InnerException);
|
result.SetException(ExpandWebException(task.Exception.InnerException));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
try{
|
try{
|
||||||
@ -59,5 +61,20 @@ string AssetDownloadUrl(JsonObject obj){
|
|||||||
|
|
||||||
return new UpdateInfo(versionTag, releaseNotes, downloadUrl, installerFolder);
|
return new UpdateInfo(versionTag, releaseNotes, downloadUrl, installerFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Exception ExpandWebException(Exception e){
|
||||||
|
if (e is WebException we && we.Response is HttpWebResponse response){
|
||||||
|
try{
|
||||||
|
using(Stream stream = response.GetResponseStream())
|
||||||
|
using(StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(response.CharacterSet ?? "utf-8"))){
|
||||||
|
return new Reporter.ExpandedLogException(e, reader.ReadToEnd());
|
||||||
|
}
|
||||||
|
}catch{
|
||||||
|
// whatever
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user