*/
class Exception: public std::exception
{
+private:
+ std::string wot;
+ std::string wer;
+ Debug::Backtrace bt;
+
public:
Exception(const std::string &);
~Exception() throw() { }
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 wot;
- std::string wer;
- Debug::Backtrace bt;
-
};
/**
*/
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);
- const std::string &get_key() const { return key; }
~KeyError() throw() { }
-private:
- std::string key;
+
+ const std::string &get_key() const { return key; }
};
/**
*/
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;
+
+public:
+ UsageError(const std::string &r, bool b = true): Exception(r), brief(b) { }
+ bool get_brief() const { return brief; }
};
/**
*/
class SystemError: public Exception
{
+private:
+ int err;
+
public:
SystemError(const std::string &, int);
int get_error_code() const { return err; }
-private:
- int 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<typename E>
void throw_at(E e, const std::string &a)
{ e.at(a); throw e; }