private static async Task DownloadFromYoutube(Downloader downloader, IEnumerable <Type> exceptionTypes, IObserver <double> progress) { try { await Task.Run(() => downloader.Execute()); } catch (Exception ex) { Exception outer = new YoutubeDownloadException("Youtube video or audio download failed", ex); if (exceptionTypes.Contains(ex.GetType())) { progress.OnError(outer); } throw outer; } progress.OnCompleted(); }
private static async Task DownloadFromYoutube(Downloader downloader, IEnumerable<Type> exceptionTypes, IObserver<double> progress) { try { await Task.Run(() => downloader.Execute()); } catch (Exception ex) { Exception outer = new YoutubeDownloadException("Youtube video or audio download failed", ex); if (exceptionTypes.Contains(ex.GetType())) { progress.OnError(outer); } throw outer; } progress.OnCompleted(); }