hmbdc
simplify-high-performance-messaging-programming
 All Classes Namespaces Functions Variables Friends Pages
Exception.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 
4 #include <sstream>
5 #include <stdexcept>
6 
7 #define HMBDC_THROW(Exception, x) {\
8  std::ostringstream os;\
9  os << x << " at " << __FILE__ << ':' << __LINE__;\
10  throw Exception(os.str()); \
11 }
12 
13 namespace hmbdc {
14  /**
15  * @brief Unknown excpetion
16  */
18  : std::exception {
20  char const* what() const noexcept override {
21  return "Unknown excpetion";
22  }
23  };
24 
25  /**
26  * @brief Exception that just has an exit code
27  */
28  struct ExitCode
29  : std::exception {
30  explicit ExitCode(int c) {
31  sprintf(code, "%d", c);
32  }
33  char const* what() const noexcept override {
34  return code;
35  }
36 
37  private:
38  char code[16];
39  };
40 }
41 
Unknown excpetion.
Definition: Exception.hpp:17
Exception that just has an exit code.
Definition: Exception.hpp:28