summaryrefslogtreecommitdiff
path: root/oss-fuzz/fuzzing/exception.hpp
blob: 55c360ded31a9511453bcd85cd829c5defc1bbd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <exception>
#include <string>

namespace fuzzing {
namespace exception {

class ExceptionBase : public std::exception {
    public:
        ExceptionBase(void) = default;
        /* typeid(T).name */
};

/* Recoverable exception */
class FlowException : public ExceptionBase {
    public:
        FlowException(void) : ExceptionBase() { }
};

/* Error in this library, should never happen */
class LogicException : public ExceptionBase {
    private:
        std::string reason;
    public:
        LogicException(const std::string r) : ExceptionBase(), reason(r) { }
        virtual const char* what(void) const throw() {
            return reason.c_str();
        }
};

/* Error in target application */
class TargetException : public ExceptionBase {
    private:
        std::string reason;
    public:
        TargetException(const std::string r) : ExceptionBase(), reason(r) { }
        virtual const char* what(void) const throw() {
            return reason.c_str();
        }
};

} /* namespace exception */
} /* namespace fuzzing */