From 6b25803a38e26d462b41fb289aa0f60b95065a23 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 14 Jul 2012 14:37:12 +0200 Subject: [PATCH] controller: don't just try/catch everything --- SparkleShare/SparkleControllerBase.cs | 54 ++++++++++++++------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index e3ac1c10..0bba3d92 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -274,9 +274,9 @@ namespace SparkleShare { new object [] {folder_path, this.config} ); - } catch { + } catch (Exception e) { SparkleHelpers.DebugInfo ("Controller", - "Failed to load \"" + backend + "\" backend for \"" + folder_name + "\""); + "Failed to load '" + backend + "' backend for '" + folder_name + "': " + e.Message); return; } @@ -512,9 +512,9 @@ namespace SparkleShare { fetch_prior_history ); - } catch { + } catch (Exception e) { SparkleHelpers.DebugInfo ("Controller", - "Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""); + "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message); if (FolderFetchError != null) FolderFetchError ( @@ -615,30 +615,32 @@ namespace SparkleShare { SparkleHelpers.ClearAttributes (this.fetcher.TargetFolder); Directory.Move (this.fetcher.TargetFolder, target_folder_path); - string backend = SparkleFetcherBase.GetBackend (this.fetcher.RemoteUrl.AbsolutePath); - this.config.AddFolder (target_folder_name, this.fetcher.Identifier, - this.fetcher.RemoteUrl.ToString (), backend); - - if (FolderFetched != null) - FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ()); - - /* TODO - if (!string.IsNullOrEmpty (announcements_url)) { - this.config.SetFolderOptionalAttribute ( - target_folder_name, "announcements_url", announcements_url); - */ - - AddRepository (target_folder_path); - - if (FolderListChanged != null) - FolderListChanged (); - - this.fetcher.Dispose (); - this.fetcher = null; - } catch (Exception e) { - SparkleHelpers.DebugInfo ("Controller", "Error adding folder: " + e.Message); + SparkleHelpers.DebugInfo ("Controller", "Error moving directory: " + e.Message); + return; } + + string backend = SparkleFetcherBase.GetBackend (this.fetcher.RemoteUrl.AbsolutePath); + + this.config.AddFolder (target_folder_name, this.fetcher.Identifier, + this.fetcher.RemoteUrl.ToString (), backend); + + if (FolderFetched != null) + FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ()); + + /* TODO + if (!string.IsNullOrEmpty (announcements_url)) { + this.config.SetFolderOptionalAttribute ( + target_folder_name, "announcements_url", announcements_url); + */ + + AddRepository (target_folder_path); + + if (FolderListChanged != null) + FolderListChanged (); + + this.fetcher.Dispose (); + this.fetcher = null; }