From 607b347dd5cf61335f1a83d7ebcb6bd61cb5be40 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 25 May 2011 01:15:30 +0100 Subject: [PATCH] config add exception when config file is not found --- SparkleLib/SparkleConfig.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index fb9e504b..c8f9e407 100644 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -16,6 +16,7 @@ using System; +using System.IO; using System.Xml; namespace SparkleLib { @@ -30,6 +31,9 @@ namespace SparkleLib { public SparkleConfig (string path) { + if (!File.Exists (path)) + throw new ConfigFileNotFoundException (path + " does not exist"); + Path = path; Load (Path); } @@ -95,4 +99,11 @@ namespace SparkleLib { Save (Path); } } -} + + + public class ConfigFileNotFoundException : Exception { + + public ConfigFileNotFoundException (string message) + : base (message) { } + } +} \ No newline at end of file