Skip to content

Commit 1c497cf

Browse files
committed
Cleaner update source error logging
1 parent f82c300 commit 1c497cf

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/KKManager.Updater/UpdateSourceManager.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using System.IO;
66
using System.Linq;
77
using System.Net;
8+
using System.Net.Sockets;
89
using System.Reactive.Linq;
10+
using System.Security;
911
using System.Threading;
1012
using System.Threading.Tasks;
1113
using KKManager.Data;
@@ -111,10 +113,19 @@ async Task DoUpdate()
111113
catch (OperationCanceledException) { }
112114
catch (Exception e)
113115
{
114-
if (e is AggregateException ae && ae.InnerExceptions.Any(x => x is OperationCanceledException))
115-
continue;
116-
else
117-
Console.WriteLine($"[ERROR] Unexpected error while collecting updates from source {task.source.Origin} - skipping the source. Error: {e.ToStringDemystified()}");
116+
if (e is AggregateException ae)
117+
{
118+
e = ae = ae.Flatten();
119+
if (ae.InnerExceptions.Any(x => x is OperationCanceledException))
120+
continue;
121+
122+
if(ae.InnerExceptions.Count == 1)
123+
e = ae.InnerExceptions[0];
124+
}
125+
126+
var noStacktrace = e is SocketException or WebException or SecurityException or OutdatedVersionException;
127+
var errorStr = noStacktrace ? e.GetType().FullName + ": " + e.Message : e.ToStringDemystified();
128+
Console.WriteLine($"[ERROR] Unexpected error while collecting updates from source {task.source.Origin} - skipping the source. Error: {errorStr}");
118129
}
119130
}
120131
progressCallback.Report(1);

0 commit comments

Comments
 (0)