mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-14 03:15:49 +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.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Script.Serialization;
|
||||
using TweetDuck.Core.Utils;
|
||||
@ -28,7 +30,7 @@ public Task<UpdateInfo> Check(){
|
||||
result.SetCanceled();
|
||||
}
|
||||
else if (task.IsFaulted){
|
||||
result.SetException(task.Exception.InnerException);
|
||||
result.SetException(ExpandWebException(task.Exception.InnerException));
|
||||
}
|
||||
else{
|
||||
try{
|
||||
@ -59,5 +61,20 @@ string AssetDownloadUrl(JsonObject obj){
|
||||
|
||||
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