diff options
Diffstat (limited to 'src')
-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 | ||||
-rw-r--r-- | src/utils/base_exception.cpp | 44 | ||||
-rw-r--r-- | src/utils/base_exception.hpp | 49 |
6 files changed, 115 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: diff --git a/src/utils/base_exception.cpp b/src/utils/base_exception.cpp new file mode 100644 index 00000000..e00ba716 --- /dev/null +++ b/src/utils/base_exception.cpp @@ -0,0 +1,44 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#include "base_exception.hpp" + +namespace usdx +{ + BaseException::BaseException(std::string message) : message(message) + { + } + + BaseException::~BaseException () throw () + { + } + + const char* BaseException::what() const throw() + { + return message.c_str(); + } + +}; diff --git a/src/utils/base_exception.hpp b/src/utils/base_exception.hpp new file mode 100644 index 00000000..44f3c2b7 --- /dev/null +++ b/src/utils/base_exception.hpp @@ -0,0 +1,49 @@ +/* + * UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef BASE_MESSAGE_EXCEPTIONS_HPP +#define BASE_MESSAGE_EXCEPTIONS_HPP + +#include <string> +#include <exception> + +namespace usdx +{ + class BaseException : public std::exception + { + private: + std::string message; + + protected: + BaseException(std::string message); + + public: + ~BaseException() throw (); + virtual const char* what() const throw(); + }; +}; + +#endif |