openMSX
MSXException.hh
Go to the documentation of this file.
1 #ifndef MSXEXCEPTION_HH
2 #define MSXEXCEPTION_HH
3 
4 #include "strCat.hh"
5 #include <string>
6 
7 namespace openmsx {
8 
10 {
11 public:
12  explicit MSXException() = default;
13 
14  explicit MSXException(std::string message_)
15  : message(std::move(message_)) {}
16 
17  template<typename... Args>
18  explicit MSXException(Args&&... args)
19  : message(strCat(std::forward<Args>(args)...))
20  {
21  }
22 
23  const std::string& getMessage() const & { return message; }
24  std::string getMessage() && { return std::move(message); }
25 
26 private:
27  std::string message;
28 };
29 
31 {
32 public:
33  explicit FatalError(std::string message_)
34  : message(std::move(message_)) {}
35 
36  template<typename... Args>
37  explicit FatalError(Args&&... args)
38  : message(strCat(std::forward<Args>(args)...))
39  {
40  }
41 
42  const std::string& getMessage() const & { return message; }
43  std::string getMessage() && { return std::move(message); }
44 
45 private:
46  std::string message;
47 };
48 
49 } // namespace openmsx
50 
51 #endif
std::string getMessage() &&
Definition: MSXException.hh:24
const std::string & getMessage() const &
Definition: MSXException.hh:23
MSXException(Args &&... args)
Definition: MSXException.hh:18
std::string getMessage() &&
Definition: MSXException.hh:43
FatalError(Args &&... args)
Definition: MSXException.hh:37
STL namespace.
MSXException(std::string message_)
Definition: MSXException.hh:14
FatalError(std::string message_)
Definition: MSXException.hh:33
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
const std::string & getMessage() const &
Definition: MSXException.hh:42
std::string strCat(Ts &&...ts)
Definition: strCat.hh:573