/src/fuzzing-headers/include/fuzzing/exception.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | #include <exception> |
4 | | #include <string> |
5 | | |
6 | | namespace fuzzing { |
7 | | namespace exception { |
8 | | |
9 | | class ExceptionBase : public std::exception { |
10 | | public: |
11 | 5.21k | ExceptionBase(void) = default; |
12 | | /* typeid(T).name */ |
13 | | }; |
14 | | |
15 | | /* Recoverable exception */ |
16 | | class FlowException : public ExceptionBase { |
17 | | public: |
18 | 5.21k | FlowException(void) : ExceptionBase() { } |
19 | | }; |
20 | | |
21 | | /* Error in this library, should never happen */ |
22 | | class LogicException : public ExceptionBase { |
23 | | private: |
24 | | std::string reason; |
25 | | public: |
26 | 0 | LogicException(const std::string reason) : ExceptionBase(), reason(reason) { } |
27 | 0 | virtual const char* what(void) const throw() { |
28 | 0 | return reason.c_str(); |
29 | 0 | } |
30 | | }; |
31 | | |
32 | | /* Error in target application */ |
33 | | class TargetException : public ExceptionBase { |
34 | | private: |
35 | | std::string reason; |
36 | | public: |
37 | 0 | TargetException(const std::string reason) : ExceptionBase(), reason(reason) { } |
38 | 0 | virtual const char* what(void) const throw() { |
39 | 0 | return reason.c_str(); |
40 | 0 | } |
41 | | }; |
42 | | |
43 | | } /* namespace exception */ |
44 | | } /* namespace fuzzing */ |