Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InexorException.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <exception>
4 #include <string>
5 #include <utility>
7 
8 namespace inexor {
9 namespace util {
10 
24 class InexorException : public std::exception {
25  std::string what_ = "Some problem occurred in the "
26  "inexor code. Dunno what.";
27 public:
28 
33 
37  InexorException(const char *s) : what_(s) {}
38 
44 
49  : std::exception(e), what_(e.what_){}
50 
52  virtual const char* clazz() {
53  return "InexorException";
54  }
55 
57  virtual std::string message() {
58  return inexor::util::fmt << clazz() << ": " << what_;
59  }
60 
61  const char* what() const noexcept override {
62  return what_.c_str();
63  }
64 };
65 
79 #define EXCEPTION(name, base, __what ) \
80  class name : public base { \
81  public: \
82  name() : base(__what) {} \
83  name(const char *s) : base(s) {} \
84  name(const std::string &s) : base(s) {} \
85  name(const InexorException &e) : base(e) {} \
86  virtual const char* clazz() noexcept { \
87  return #name ; \
88  } \
89  }
90 
93 #define IEXCEPTION(name, __what) \
94  EXCEPTION(name, ::inexor::util::InexorException, __what)
95 
96 }
97 }
InexorException(std::string s)
Initialize this exception with a custom error message.
Definition: InexorException.hpp:43
StringFormatter::FmtMark fmt
Marker that starts formatting a string.
Definition: StringFormatter.cpp:5
InexorException(const InexorException &e)
Initialize this exception with a custom error message in a string.
Definition: InexorException.hpp:48
std::string what_
Definition: InexorException.hpp:25
virtual std::string message()
Generates an error message appropriate for logging.
Definition: InexorException.hpp:57
Basic exception type for use in inexor.
Definition: InexorException.hpp:24
InexorException(const char *s)
Initialize this exception with a custom error message.
Definition: InexorException.hpp:37
bool move(physent *d, vec &dir)
Definition: physics.cpp:1342
char string[MAXSTRLEN]
cube-strings (char arrays of fixed size).
Definition: cube_types.hpp:18
const char * what() const noexceptoverride
Definition: InexorException.hpp:61
virtual const char * clazz()
The name of this exception class.
Definition: InexorException.hpp:52
InexorException()
Default constructor.
Definition: InexorException.hpp:32