3 This file is part of libmspcore
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
7 #ifndef MSP_CORE_ERROR_H_
8 #define MSP_CORE_ERROR_H_
12 #include "../debug/backtrace.h"
17 Base class for all Msp exceptions.
19 class Exception: public std::exception
22 Exception(const std::string &);
23 ~Exception() throw() { }
25 const char *what() const throw() { return w.c_str(); }
26 const Debug::Backtrace &get_backtrace() const throw() { return bt; }
34 Thrown when a function parameter has an invalid value.
36 class InvalidParameterValue: public Exception
39 InvalidParameterValue(const std::string &w_): Exception(w_) { }
43 Thrown when a lookup from a map fails.
45 class KeyError: public Exception
48 KeyError(const std::string &w_): Exception(w_) { }
52 Thrown when the current object state doesn't allow the requested action.
54 class InvalidState: public Exception
57 InvalidState(const std::string &w_): Exception(w_) { }
61 Thrown when the application is invoked with wrong parameters.
63 class UsageError: public Exception
66 UsageError(const std::string &r, bool b=true): Exception(r), brief(b) { }
67 bool get_brief() const { return brief; }
73 Thrown when a system call fails.
75 class SystemError: public Exception
78 SystemError(const std::string &, int);
79 int get_error_code() const { return err; }
83 static std::string build_what(const std::string &, int);