Sort includes in C++ files
[babeltrace.git] / src / cpp-common / exc.hpp
CommitLineData
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>
f197dce3
FD
11#include <new>
12#include <stdexcept>
c802cacb 13#include <string>
f197dce3
FD
14
15namespace bt2_common {
16
17/*
18 * End of iteration.
19 */
20class End : public std::exception
21{
22public:
23 explicit End() noexcept : std::exception {}
24 {
25 }
26};
27
28/*
29 * General error.
30 */
31class Error : public std::runtime_error
32{
33public:
34 explicit Error(std::string msg = "Error") : std::runtime_error {std::move(msg)}
35 {
36 }
37};
38
f1380b36
PP
39/*
40 * Overflow error.
41 */
42class OverflowError : public Error
43{
44public:
45 explicit OverflowError() noexcept : Error {"Overflow error"}
46 {
47 }
48};
49
f197dce3
FD
50/*
51 * Memory error.
52 */
53class MemoryError : public std::bad_alloc
54{
55public:
56 explicit MemoryError() noexcept : std::bad_alloc {}
57 {
58 }
59};
60
61/*
62 * Not available right now: try again later.
63 */
64class TryAgain : public std::exception
65{
66public:
67 explicit TryAgain() noexcept : std::exception {}
68 {
69 }
70};
71
72} /* namespace bt2_common */
73
74#endif /* BABELTRACE_CPP_COMMON_EXC_HPP */
This page took 0.027912 seconds and 4 git commands to generate.