cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / cpp-common / bt2c / exc.hpp
1 /*
2 * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2C_EXC_HPP
8 #define BABELTRACE_CPP_COMMON_BT2C_EXC_HPP
9
10 #include <exception>
11 #include <new>
12 #include <stdexcept>
13 #include <string>
14
15 namespace bt2c {
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 * Overflow error.
41 */
42 class OverflowError : public Error
43 {
44 public:
45 explicit OverflowError() noexcept : Error {"Overflow error"}
46 {
47 }
48 };
49
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 /*
73 * No such file or directory.
74 */
75 class NoSuchFileOrDirectoryError : public Error
76 {
77 public:
78 explicit NoSuchFileOrDirectoryError() noexcept : Error {"No such file or directory"}
79 {
80 }
81 };
82
83 } /* namespace bt2c */
84
85 #endif /* BABELTRACE_CPP_COMMON_BT2C_EXC_HPP */
This page took 0.031878 seconds and 4 git commands to generate.