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 | ||
f1380b36 PP |
39 | /* |
40 | * Overflow error. | |
41 | */ | |
42 | class OverflowError : public Error | |
43 | { | |
44 | public: | |
45 | explicit OverflowError() noexcept : Error {"Overflow error"} | |
46 | { | |
47 | } | |
48 | }; | |
49 | ||
f197dce3 FD |
50 | /* |
51 | * Memory error. | |
52 | */ | |
53 | class MemoryError : public std::bad_alloc | |
54 | { | |
55 | public: | |
56 | explicit MemoryError() noexcept : std::bad_alloc {} | |
57 | { | |
58 | } | |
59 | }; | |
60 | ||
61 | /* | |
62 | * Not available right now: try again later. | |
63 | */ | |
64 | class TryAgain : public std::exception | |
65 | { | |
66 | public: | |
67 | explicit TryAgain() noexcept : std::exception {} | |
68 | { | |
69 | } | |
70 | }; | |
71 | ||
72 | } /* namespace bt2_common */ | |
73 | ||
74 | #endif /* BABELTRACE_CPP_COMMON_EXC_HPP */ |