X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fexcept.h;h=1673ff46a4c528764988bb7520cf0a5a9f0ef6d8;hb=HEAD;hp=a18e028730aedddac1d044de1b98b4fa36edea21;hpb=9de64375e03b24ea46d36cec222150754e3818cb;p=libs%2Fcore.git diff --git a/source/core/except.h b/source/core/except.h index a18e028..1673ff4 100644 --- a/source/core/except.h +++ b/source/core/except.h @@ -1,92 +1,38 @@ -/* $Id$ +#ifndef MSP_CORE_EXCEPT_H_ +#define MSP_CORE_EXCEPT_H_ -This file is part of libmspcore -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ -#ifndef MSP_CORE_ERROR_H_ -#define MSP_CORE_ERROR_H_ - -#include -#include -#include "../debug/backtrace.h" +#include +#include "mspcore_api.h" namespace Msp { -/** -Base class for all Msp exceptions. -*/ -class Exception: public std::exception +class MSPCORE_API invalid_state: public std::logic_error { 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; - + invalid_state(const std::string &w): logic_error(w) { } }; -/** -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 +class MSPCORE_API already_called: public invalid_state { public: - KeyError(const std::string &w_): Exception(w_) { } - KeyError(const std::string &w_, const std::string &k) { } - const std::string &get_key() const { return key; } -private: - std::string key; + already_called(const std::string &w): invalid_state(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 +class MSPCORE_API unsupported: public std::logic_error { public: - UsageError(const std::string &r, bool b=true): Exception(r), brief(b) { } - bool get_brief() const { return brief; } -private: - bool brief; + unsupported(const std::string &w): logic_error(w) { } }; -/** -Thrown when a system call fails. -*/ -class SystemError: public Exception + +class MSPCORE_API internal_error: public std::logic_error { 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); + internal_error(const std::string &w): logic_error(w) { } }; -} // namespace Msp +} // namespace Msp; #endif