diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-01-20 03:43:31 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-05 17:17:45 +0100 |
commit | 22aa1302d76342c7c4b56b7380734a7f984e7411 (patch) | |
tree | a75880a07b4c32967bc01d3e2d39231f6054d4e3 /src/base | |
parent | c139750658c14e8e0a2621044473810027486f50 (diff) | |
download | usdx-22aa1302d76342c7c4b56b7380734a7f984e7411.tar.gz usdx-22aa1302d76342c7c4b56b7380734a7f984e7411.tar.xz usdx-22aa1302d76342c7c4b56b7380734a7f984e7411.zip |
added custom exception classes for better catching them (gotta catch 'em all)
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/song.cpp | 8 | ||||
-rw-r--r-- | src/base/song.hpp | 8 | ||||
-rw-r--r-- | src/base/songloading/songloader.cpp | 4 | ||||
-rw-r--r-- | src/base/songloading/songloader.hpp | 8 |
4 files changed, 22 insertions, 6 deletions
diff --git a/src/base/song.cpp b/src/base/song.cpp index 3d825bf4..4185d51b 100644 --- a/src/base/song.cpp +++ b/src/base/song.cpp @@ -108,7 +108,7 @@ namespace usdx } else if (required) { LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'"); - throw "Incomplete Song! Missing Tag."; + throw MissingSongTagException("Incomplete Song! Missing Tag."); } return result; @@ -125,7 +125,7 @@ namespace usdx } else if (required) { LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'"); - throw "Incomplete Song! Missing Tag."; + throw MissingSongTagException("Incomplete Song! Missing Tag."); } return result; @@ -143,7 +143,7 @@ namespace usdx } else if (required) { LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'"); - throw "Incomplete Song! Missing Tag."; + throw MissingSongTagException("Incomplete Song! Missing Tag."); } return result; @@ -164,7 +164,7 @@ namespace usdx } else if (required) { LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'"); - throw "Incomplete Song! Missing Tag."; + throw MissingSongTagException("Incomplete Song! Missing Tag."); } return result; diff --git a/src/base/song.hpp b/src/base/song.hpp index d7ed8c98..6009cfa9 100644 --- a/src/base/song.hpp +++ b/src/base/song.hpp @@ -33,9 +33,17 @@ #include <log4cxx/logger.h> #include "bpm.hpp" #include "lyric_line.hpp" +#include "utils/base_exception.hpp" namespace usdx { + class MissingSongTagException : public BaseException + { + public: + MissingSongTagException(std::string message) : BaseException(message) {}; + ~MissingSongTagException () throw () {}; + }; + class Song { private: diff --git a/src/base/songloading/songloader.cpp b/src/base/songloading/songloader.cpp index 0b1e34ad..c5c595d4 100644 --- a/src/base/songloading/songloader.cpp +++ b/src/base/songloading/songloader.cpp @@ -74,7 +74,7 @@ namespace usdx std::map<std::string, SongloadingStrategy*>::iterator it = strategies.find(extension); if (it == strategies.end()) { LOG4CXX_WARN(log, "No SongloadingStrategy found for file extension: '" << extension << "'"); - throw "Unknown file format."; + throw NoStrategyException("Unknown file format."); } return it->second->load_header(filename); @@ -92,7 +92,7 @@ namespace usdx std::map<std::string, SongloadingStrategy*>::iterator it = strategies.find(extension); if (it == strategies.end()) { LOG4CXX_WARN(log, "No SongloadingStrategy found for file extension: '" << extension << "'"); - throw "Unknown file format."; + throw NoStrategyException("Unknown file format."); } return it->second->load_song(song); diff --git a/src/base/songloading/songloader.hpp b/src/base/songloading/songloader.hpp index 41f7e034..bbe7dfcb 100644 --- a/src/base/songloading/songloader.hpp +++ b/src/base/songloading/songloader.hpp @@ -31,9 +31,17 @@ #include <log4cxx/logger.h> #include "songloading_strategy.hpp" #include "song.hpp" +#include "utils/base_exception.hpp" namespace usdx { + class NoStrategyException : public BaseException + { + public: + NoStrategyException(std::string message) : BaseException(message) {}; + ~NoStrategyException () throw () {}; + }; + class Songloader { private: |