X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fexcept.h;fp=source%2Fcore%2Fexcept.h;h=0000000000000000000000000000000000000000;hb=da2572104375f25b16d392dd14ea208a6f7e57d7;hp=ed295f11cef6c50d7fb1c407a7c89852e2d8b2b6;hpb=e14321c38b34ec1cc5641b267f031693a8f7bc27;p=libs%2Fcore.git diff --git a/source/core/except.h b/source/core/except.h deleted file mode 100644 index ed295f1..0000000 --- a/source/core/except.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef MSP_CORE_ERROR_H_ -#define MSP_CORE_ERROR_H_ - -#include -#include -#include - -namespace Msp { - -/** -Base class for all Msp exceptions. -*/ -class Exception: public std::exception -{ -private: - std::string wot; - std::string wer; - Debug::Backtrace bt; - -public: - Exception(const std::string &); - ~Exception() throw() { } - - const char *what() const throw() { return wot.c_str(); } - Exception &at(const std::string &) throw(); - const char *where() const throw() { return wer.c_str(); } - const Debug::Backtrace &get_backtrace() const throw() { return 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 -{ -private: - std::string key; - -public: - KeyError(const std::string &w_): Exception(w_) { } - KeyError(const std::string &w_, const std::string &k); - ~KeyError() throw() { } - - const std::string &get_key() const { return key; } -}; - -/** -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 -{ -private: - bool brief; - -public: - UsageError(const std::string &r, bool b = true): Exception(r), brief(b) { } - bool get_brief() const { return brief; } -}; - -/** -Thrown when a system call fails. -*/ -class SystemError: public Exception -{ -private: - int err; - -public: - SystemError(const std::string &, int); - int get_error_code() const { return err; } - -private: - static std::string build_what(const std::string &, int); -}; - -/** -Thrown when "impossible" things happen. -*/ -class LogicError: public Exception -{ -public: - LogicError(const std::string &w_): Exception(w_) { } -}; - -template -void throw_at(E e, const std::string &a) -{ e.at(a); throw e; } - -} // namespace Msp - -#endif