Commit | Line | Data |
---|---|---|
f197dce3 FD |
1 | /* |
2 | * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: MIT | |
5 | */ | |
6 | ||
7 | #ifndef BABELTRACE_CPP_COMMON_EXC_HPP | |
8 | #define BABELTRACE_CPP_COMMON_EXC_HPP | |
9 | ||
10 | #include <exception> | |
11 | #include <string> | |
12 | #include <new> | |
13 | #include <stdexcept> | |
14 | ||
15 | namespace bt2_common { | |
16 | ||
17 | /* | |
18 | * End of iteration. | |
19 | */ | |
20 | class End : public std::exception | |
21 | { | |
22 | public: | |
23 | explicit End() noexcept : std::exception {} | |
24 | { | |
25 | } | |
26 | }; | |
27 | ||
28 | /* | |
29 | * General error. | |
30 | */ | |
31 | class Error : public std::runtime_error | |
32 | { | |
33 | public: | |
34 | explicit Error(std::string msg = "Error") : std::runtime_error {std::move(msg)} | |
35 | { | |
36 | } | |
37 | }; | |
38 | ||
39 | /* | |
40 | * Memory error. | |
41 | */ | |
42 | class MemoryError : public std::bad_alloc | |
43 | { | |
44 | public: | |
45 | explicit MemoryError() noexcept : std::bad_alloc {} | |
46 | { | |
47 | } | |
48 | }; | |
49 | ||
50 | /* | |
51 | * Not available right now: try again later. | |
52 | */ | |
53 | class TryAgain : public std::exception | |
54 | { | |
55 | public: | |
56 | explicit TryAgain() noexcept : std::exception {} | |
57 | { | |
58 | } | |
59 | }; | |
60 | ||
61 | } /* namespace bt2_common */ | |
62 | ||
63 | #endif /* BABELTRACE_CPP_COMMON_EXC_HPP */ |