From 3c55ea163a765c3cf68d51601bb64ebb9c201e41 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 15 Feb 2011 08:15:12 +0000 Subject: Improved error messages from ConfigrationParser. --- server/src/configurationparser.h | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'server/src/configurationparser.h') diff --git a/server/src/configurationparser.h b/server/src/configurationparser.h index 924c041..8e0c01d 100644 --- a/server/src/configurationparser.h +++ b/server/src/configurationparser.h @@ -30,16 +30,7 @@ #include #include -#include "exception.h" - -/** - * This exception is thrown by Configuration when reload fails. - */ -class ConfigurationParserException: public Exception { -public: - ConfigurationParserException(std::string reason) : - Exception(reason) {} -}; +#include /** * This is the pentominos configuration class.\n @@ -50,17 +41,40 @@ public: */ class ConfigurationParser : public libconfig::Config { public: + /** + * This exception is thrown by Configuration when reload fails. + */ + class ParseException: public std::exception { + public: + ParseException(int line, std::string err) throw() : l(line), e(err) {} + ~ParseException() throw() {} + const char *what() throw(); + + private: + std::string _what; + int l; + std::string e; + }; + + /** + * This exception is thrown by Configuration when file read fails. + */ + class ReadException: public std::exception {}; + + /** * Constructor.\n * @param filename The filename to be loaded. */ - ConfigurationParser(std::string filename); + ConfigurationParser(std::string filename) + throw(ParseException, ReadException); /** * reload, simply reloads the configuration file attached to the configuration * object. */ - void reload() throw(ConfigurationParserException); + void reload() + throw(ParseException, ReadException); private: std::string filename; -- cgit v1.2.3