From: Mikko Rasa Date: Wed, 5 Dec 2007 15:21:01 +0000 (+0000) Subject: Store the failed key in KeyError X-Git-Tag: 1.0~13 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=9de64375e03b24ea46d36cec222150754e3818cb;hp=ce8b99f8d48b7783fd97f3959198f9c54cebec72;p=libs%2Fcore.git Store the failed key in KeyError --- diff --git a/source/core/except.cpp b/source/core/except.cpp index 245bc05..4b6e465 100644 --- a/source/core/except.cpp +++ b/source/core/except.cpp @@ -24,6 +24,11 @@ SystemError::SystemError(const string &w_, int e): err(e) { } +KeyError::KeyError(const string &w_, const string &k): + Exception(w_+" ("+k+")"), + key(k) +{ } + string SystemError::build_what(const string &w, int e) { ostringstream buf; diff --git a/source/core/except.h b/source/core/except.h index d030c41..a18e028 100644 --- a/source/core/except.h +++ b/source/core/except.h @@ -46,6 +46,10 @@ 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; } +private: + std::string key; }; /**