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         ExceptionBase(void) = default;
12         /* typeid(T).name */
13 };
14 
15 /* Recoverable exception */
16 class FlowException : public ExceptionBase {
17     public:
FlowException(void)18         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:
LogicException(const std::string r)26         LogicException(const std::string r) : ExceptionBase(), reason(r) { }
what(void) const27         virtual const char* what(void) const throw() {
28             return reason.c_str();
29         }
30 };
31 
32 /* Error in target application */
33 class TargetException : public ExceptionBase {
34     private:
35         std::string reason;
36     public:
TargetException(const std::string r)37         TargetException(const std::string r) : ExceptionBase(), reason(r) { }
what(void) const38         virtual const char* what(void) const throw() {
39             return reason.c_str();
40         }
41 };
42 
43 } /* namespace exception */
44 } /* namespace fuzzing */
45