From 44572da5c7c956d7f020fe9f4edab94b04cb2f7c Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 25 May 2011 01:20:37 +0100 Subject: [PATCH] config: throw exception whenever config file doesn't exist --- SparkleLib/SparkleConfig.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index c8f9e407..1a426fa6 100644 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -49,7 +49,7 @@ namespace SparkleLib { XmlNode node = SelectSingleNode ("//user/name/text()"); node.InnerText = value; - Save (Path); + Save (); } } @@ -64,7 +64,7 @@ namespace SparkleLib { XmlNode node = SelectSingleNode ("//user/name/email()"); node.InnerText = value; - Save (Path); + Save (); } } @@ -85,7 +85,7 @@ namespace SparkleLib { XmlNode node_root = SelectSingleNode ("/"); node_root.AppendChild (node_folder); - Save (Path); + Save (); } @@ -96,7 +96,16 @@ namespace SparkleLib { SelectSingleNode ("/").RemoveChild (node_folder); } - Save (Path); + Save (); + } + + + public void Save () + { + if (!File.Exists (Path)) + throw new ConfigFileNotFoundException (Path + " does not exist"); + + base.Save (Path); } }