3 This file is part of libmspcore
4 Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_CORE_ERROR_H_
9 #define MSP_CORE_ERROR_H_
13 #include "../debug/backtrace.h"
18 Base class for all Msp exceptions.
20 class Exception: public std::exception
23 Exception(const std::string &);
24 ~Exception() throw() { }
26 const char *what() const throw() { return wot.c_str(); }
27 Exception &at(const std::string &) throw();
28 const char *where() const throw() { return wer.c_str(); }
29 const Debug::Backtrace &get_backtrace() const throw() { return bt; }
38 Thrown when a function parameter has an invalid value.
40 class InvalidParameterValue: public Exception
43 InvalidParameterValue(const std::string &w_): Exception(w_) { }
47 Thrown when a lookup from a map fails.
49 class KeyError: public Exception
52 KeyError(const std::string &w_): Exception(w_) { }
53 KeyError(const std::string &w_, const std::string &k);
54 const std::string &get_key() const { return key; }
55 ~KeyError() throw() { }
61 Thrown when the current object state doesn't allow the requested action.
63 class InvalidState: public Exception
66 InvalidState(const std::string &w_): Exception(w_) { }
70 Thrown when the application is invoked with wrong parameters.
72 class UsageError: public Exception
75 UsageError(const std::string &r, bool b=true): Exception(r), brief(b) { }
76 bool get_brief() const { return brief; }
82 Thrown when a system call fails.
84 class SystemError: public Exception
87 SystemError(const std::string &, int);
88 int get_error_code() const { return err; }
92 static std::string build_what(const std::string &, int);
96 void throw_at(E e, const std::string &a)