UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
exceptions.h
Go to the documentation of this file.
1 #ifndef UGDK_SYSTEM_EXCEPTIONS_H_
2 #define UGDK_SYSTEM_EXCEPTIONS_H_
3 
4 #include <string>
5 
6 namespace ugdk {
7 namespace system {
8 
9 class BaseException {
10  public:
11  BaseException(const char * fmt, ...);
12  virtual ~BaseException() throw() {}
13 
14  inline virtual const char * what() const throw() {
15  return reason_.c_str();
16  }
17 
18  private:
19  std::string reason_;
20 };
21 
23  public:
24  InvalidOperation(const char* reason) : BaseException(reason) {}
25 };
26 
27 template<class T, typename ...Args>
28 void AssertCondition(bool condition, Args... args) {
29  if (!condition) {
30  throw T(std::forward<Args>(args)...);
31  }
32 }
33 
34 } // namespace system
35 } // namespace ugdk
36 
37 #endif // UGDK_SYSTEM_EXCEPTIONS_H_
Definition: animation.h:11
void AssertCondition(bool condition, Args...args)
Definition: exceptions.h:28
virtual ~BaseException()
Definition: exceptions.h:12
InvalidOperation(const char *reason)
Definition: exceptions.h:24
virtual const char * what() const
Definition: exceptions.h:14
BaseException(const char *fmt,...)
Definition: exceptions.h:9
Definition: exceptions.h:22