From: Mikko Rasa Date: Thu, 4 Oct 2007 20:13:32 +0000 (+0000) Subject: Rename error.* to except.* X-Git-Tag: 1.0~18 X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=c13c5d2e330e4cee177c1fd8e0b6153c7e2503e4 Rename error.* to except.* --- diff --git a/source/core/application.cpp b/source/core/application.cpp index 3a663db..e1a9314 100644 --- a/source/core/application.cpp +++ b/source/core/application.cpp @@ -11,7 +11,7 @@ Distributed under the LGPL #include "../time/units.h" #include "../time/utils.h" #include "application.h" -#include "error.h" +#include "except.h" using namespace std; diff --git a/source/core/error.cpp b/source/core/error.cpp deleted file mode 100644 index defed2f..0000000 --- a/source/core/error.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ -#include -#include "error.h" - -using namespace std; - -namespace Msp { - -Exception::Exception(const string &w_): - w(w_) -{ -#ifdef WITH_EXCEPTION_BACKTRACE - bt=Debug::Backtrace::create(); -#endif -} - -SystemError::SystemError(const string &w_, int e): - Exception(build_what(w_, e)), - err(e) -{ } - -string SystemError::build_what(const string &w, int e) -{ - ostringstream buf; - buf< -#include -#include "../debug/backtrace.h" - -namespace Msp { - -/** -Base class for all Msp exceptions. -*/ -class Exception: public std::exception -{ -public: - Exception(const std::string &); - ~Exception() throw() { } - - const char *what() const throw() { return w.c_str(); } - const Debug::Backtrace &get_backtrace() const throw() { return bt; } -private: - std::string w; - Debug::Backtrace bt; - -}; - -/** -Thrown when a function parameter has an invalid value. -*/ -class InvalidParameterValue: public Exception -{ -public: - InvalidParameterValue(const std::string &w_): Exception(w_) { } -}; - -/** -Thrown when a lookup from a map fails. -*/ -class KeyError: public Exception -{ -public: - KeyError(const std::string &w_): Exception(w_) { } -}; - -/** -Thrown when the current object state doesn't allow the requested action. -*/ -class InvalidState: public Exception -{ -public: - InvalidState(const std::string &w_): Exception(w_) { } -}; - -/** -Thrown when the application is invoked with wrong parameters. -*/ -class UsageError: public Exception -{ -public: - UsageError(const std::string &r, bool b=true): Exception(r), brief(b) { } - bool get_brief() const { return brief; } -private: - bool brief; -}; - -/** -Thrown when a system call fails. -*/ -class SystemError: public Exception -{ -public: - SystemError(const std::string &, int); - int get_error_code() const { return err; } -private: - int err; - - static std::string build_what(const std::string &, int); -}; - -} // namespace Msp - -#endif diff --git a/source/core/except.cpp b/source/core/except.cpp new file mode 100644 index 0000000..245bc05 --- /dev/null +++ b/source/core/except.cpp @@ -0,0 +1,39 @@ +/* $Id$ + +This file is part of libmspcore +Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ +#include +#include "except.h" + +using namespace std; + +namespace Msp { + +Exception::Exception(const string &w_): + w(w_) +{ +#ifdef WITH_EXCEPTION_BACKTRACE + bt=Debug::Backtrace::create(); +#endif +} + +SystemError::SystemError(const string &w_, int e): + Exception(build_what(w_, e)), + err(e) +{ } + +string SystemError::build_what(const string &w, int e) +{ + ostringstream buf; + buf< +#include +#include "../debug/backtrace.h" + +namespace Msp { + +/** +Base class for all Msp exceptions. +*/ +class Exception: public std::exception +{ +public: + Exception(const std::string &); + ~Exception() throw() { } + + const char *what() const throw() { return w.c_str(); } + const Debug::Backtrace &get_backtrace() const throw() { return bt; } +private: + std::string w; + Debug::Backtrace bt; + +}; + +/** +Thrown when a function parameter has an invalid value. +*/ +class InvalidParameterValue: public Exception +{ +public: + InvalidParameterValue(const std::string &w_): Exception(w_) { } +}; + +/** +Thrown when a lookup from a map fails. +*/ +class KeyError: public Exception +{ +public: + KeyError(const std::string &w_): Exception(w_) { } +}; + +/** +Thrown when the current object state doesn't allow the requested action. +*/ +class InvalidState: public Exception +{ +public: + InvalidState(const std::string &w_): Exception(w_) { } +}; + +/** +Thrown when the application is invoked with wrong parameters. +*/ +class UsageError: public Exception +{ +public: + UsageError(const std::string &r, bool b=true): Exception(r), brief(b) { } + bool get_brief() const { return brief; } +private: + bool brief; +}; + +/** +Thrown when a system call fails. +*/ +class SystemError: public Exception +{ +public: + SystemError(const std::string &, int); + int get_error_code() const { return err; } +private: + int err; + + static std::string build_what(const std::string &, int); +}; + +} // namespace Msp + +#endif diff --git a/source/core/getopt.h b/source/core/getopt.h index 3315108..77cf4f2 100644 --- a/source/core/getopt.h +++ b/source/core/getopt.h @@ -10,7 +10,7 @@ Distributed under the LGPL #include #include #include -#include "error.h" +#include "except.h" namespace Msp { diff --git a/source/time/datetime.cpp b/source/time/datetime.cpp index d74fc6f..8886139 100644 --- a/source/time/datetime.cpp +++ b/source/time/datetime.cpp @@ -1,7 +1,7 @@ /* $Id$ */ #include #include -#include "../core/error.h" +#include "../core/except.h" #include "datetime.h" #include "timestamp.h"