diff options
author | deva <deva> | 2011-02-15 08:15:12 +0000 |
---|---|---|
committer | deva <deva> | 2011-02-15 08:15:12 +0000 |
commit | 3c55ea163a765c3cf68d51601bb64ebb9c201e41 (patch) | |
tree | e718db47c9515d2ff27eb6fa22ac2349d3d29c58 /server/src/configurationparser.h | |
parent | 634d7661ec1d6d202685cafb958b5a55dc2498aa (diff) |
Improved error messages from ConfigrationParser.
Diffstat (limited to 'server/src/configurationparser.h')
-rw-r--r-- | server/src/configurationparser.h | 38 |
1 files changed, 26 insertions, 12 deletions
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 <libconfig.h++> #include <string> -#include "exception.h" - -/** - * This exception is thrown by Configuration when reload fails. - */ -class ConfigurationParserException: public Exception { -public: - ConfigurationParserException(std::string reason) : - Exception(reason) {} -}; +#include <exception> /** * This is the pentominos configuration class.\n @@ -51,16 +42,39 @@ 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; |