| 1 | /* |
| 2 | * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #ifndef BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP |
| 8 | #define BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP |
| 9 | |
| 10 | #include <string> |
| 11 | #include <stdexcept> |
| 12 | |
| 13 | namespace bt2 { |
| 14 | |
| 15 | /* |
| 16 | * Any library error. |
| 17 | */ |
| 18 | class LibError : public std::runtime_error |
| 19 | { |
| 20 | public: |
| 21 | explicit LibError(const std::string& msg = "Error") : std::runtime_error {msg} |
| 22 | { |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | /* |
| 27 | * Memory error. |
| 28 | */ |
| 29 | class LibMemoryError : public LibError |
| 30 | { |
| 31 | public: |
| 32 | LibMemoryError() : LibError {"Memory error"} |
| 33 | { |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | /* |
| 38 | * Overflow error. |
| 39 | */ |
| 40 | class LibOverflowError : public LibError |
| 41 | { |
| 42 | public: |
| 43 | LibOverflowError() : LibError {"Overflow error"} |
| 44 | { |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | } // namespace bt2 |
| 49 | |
| 50 | #endif // BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP |