protected override void AddDownloadToList(string url, string destination, string username, string password) { Credentials = new NetworkCredential(username, password); try { foreach (Download download in GetFTPDownloadTree(new List <Download>(), Credentials, destination, url, url)) { try {//this inner try catch will prevent the rest of the downloads to not be added in case this one fails string newDestination = download.Destination.FullPath; download.Destination.FullPath = destination; DownloadsController.AddDownloadToList(download); download.Destination.FullPath = newDestination; } catch (Exception ex) { OnProcessError(new DownloadErrorEventArgs(ex)); } } } catch (Exception ex) { if (ex.Message.Contains("logged in")) { throw new DownloaderUCException(ErrorType.NotLoggedIn); } else { DownloaderUCException.Throw(ex); } } }
public void MainTest() { DownloaderUCException exception = new DownloaderUCException(""); Assert.Throws(typeof(DownloaderUCException), delegate { DownloaderUCException.Throw(exception); }); Assert.Throws(typeof(Exception), delegate { DownloaderUCException.Throw(new Exception()); }); Assert.Throws(typeof(DownloaderUCException), delegate { DownloaderUCException.ThrowNewGeneral(exception); }); }