X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fexcept.h;h=fc6fcc6c69921f48205fea5434a9b8da5cb05671;hb=7db1e6d50594b47a32ecca5a349a4e8540f890c0;hp=d030c41c12937e1a3846ce819c445cd2b953e308;hpb=c13c5d2e330e4cee177c1fd8e0b6153c7e2503e4;p=libs%2Fcore.git diff --git a/source/core/except.h b/source/core/except.h index d030c41..fc6fcc6 100644 --- a/source/core/except.h +++ b/source/core/except.h @@ -1,9 +1,10 @@ /* $Id$ This file is part of libmspcore -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + #ifndef MSP_CORE_ERROR_H_ #define MSP_CORE_ERROR_H_ @@ -22,10 +23,13 @@ public: Exception(const std::string &); ~Exception() throw() { } - const char *what() const throw() { return w.c_str(); } + 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; } private: - std::string w; + std::string wot; + std::string wer; Debug::Backtrace bt; }; @@ -46,6 +50,11 @@ class KeyError: public Exception { 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; } + ~KeyError() throw() { } +private: + std::string key; }; /** @@ -83,6 +92,10 @@ private: static std::string build_what(const std::string &, int); }; +template +void throw_at(E e, const std::string &a) +{ e.at(a); throw e; } + } // namespace Msp #endif