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() &&
const std::string & getMessage() const &
FatalError(Args &&... args)
FatalError(std::string message_)
MSXException(std::string message_)
std::string getMessage() &&
const std::string & getMessage() const &
MSXException(Args &&... args)
This file implemented 3 utility functions:
Definition Autofire.cc:9
STL namespace.
std::string strCat()
Definition strCat.hh:703