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
7namespace openmsx {
8
10{
11public:
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 [[nodiscard]] const std::string& getMessage() const & { return message; }
24 [[nodiscard]] std::string getMessage() && { return std::move(message); }
25
26private:
27 std::string message;
28};
29
31{
32public:
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 [[nodiscard]] const std::string& getMessage() const & { return message; }
43 [[nodiscard]] std::string getMessage() && { return std::move(message); }
44
45private:
46 std::string message;
47};
48
49} // namespace openmsx
50
51#endif
std::string getMessage() &&
Definition: MSXException.hh:43
const std::string & getMessage() const &
Definition: MSXException.hh:42
FatalError(Args &&... args)
Definition: MSXException.hh:37
FatalError(std::string message_)
Definition: MSXException.hh:33
MSXException(std::string message_)
Definition: MSXException.hh:14
std::string getMessage() &&
Definition: MSXException.hh:24
const std::string & getMessage() const &
Definition: MSXException.hh:23
MSXException(Args &&... args)
Definition: MSXException.hh:18
This file implemented 3 utility functions:
Definition: Autofire.cc:9
STL namespace.
std::string strCat(Ts &&...ts)
Definition: strCat.hh:549