1*600f14f4SXin Li /* Copyright 2019 Guido Vranken 2*600f14f4SXin Li * 3*600f14f4SXin Li * Permission is hereby granted, free of charge, to any person obtaining 4*600f14f4SXin Li * a copy of this software and associated documentation files (the 5*600f14f4SXin Li * "Software"), to deal in the Software without restriction, including 6*600f14f4SXin Li * without limitation the rights to use, copy, modify, merge, publish, 7*600f14f4SXin Li * distribute, sublicense, and/or sell copies of the Software, and to 8*600f14f4SXin Li * permit persons to whom the Software is furnished to do so, subject 9*600f14f4SXin Li * to the following conditions: 10*600f14f4SXin Li * 11*600f14f4SXin Li * The above copyright notice and this permission notice shall be 12*600f14f4SXin Li * included in all copies or substantial portions of the Software. 13*600f14f4SXin Li * 14*600f14f4SXin Li * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15*600f14f4SXin Li * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16*600f14f4SXin Li * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17*600f14f4SXin Li * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18*600f14f4SXin Li * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19*600f14f4SXin Li * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20*600f14f4SXin Li * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21*600f14f4SXin Li * SOFTWARE. 22*600f14f4SXin Li */ 23*600f14f4SXin Li 24*600f14f4SXin Li #pragma once 25*600f14f4SXin Li 26*600f14f4SXin Li #include <exception> 27*600f14f4SXin Li #include <string> 28*600f14f4SXin Li 29*600f14f4SXin Li namespace fuzzing { 30*600f14f4SXin Li namespace exception { 31*600f14f4SXin Li 32*600f14f4SXin Li class ExceptionBase : public std::exception { 33*600f14f4SXin Li public: 34*600f14f4SXin Li ExceptionBase(void) = default; 35*600f14f4SXin Li /* typeid(T).name */ 36*600f14f4SXin Li }; 37*600f14f4SXin Li 38*600f14f4SXin Li /* Recoverable exception */ 39*600f14f4SXin Li class FlowException : public ExceptionBase { 40*600f14f4SXin Li public: FlowException(void)41*600f14f4SXin Li FlowException(void) : ExceptionBase() { } 42*600f14f4SXin Li }; 43*600f14f4SXin Li 44*600f14f4SXin Li /* Error in this library, should never happen */ 45*600f14f4SXin Li class LogicException : public ExceptionBase { 46*600f14f4SXin Li private: 47*600f14f4SXin Li std::string reason; 48*600f14f4SXin Li public: LogicException(const std::string r)49*600f14f4SXin Li LogicException(const std::string r) : ExceptionBase(), reason(r) { } what(void) const50*600f14f4SXin Li virtual const char* what(void) const throw() { 51*600f14f4SXin Li return reason.c_str(); 52*600f14f4SXin Li } 53*600f14f4SXin Li }; 54*600f14f4SXin Li 55*600f14f4SXin Li /* Error in target application */ 56*600f14f4SXin Li class TargetException : public ExceptionBase { 57*600f14f4SXin Li private: 58*600f14f4SXin Li std::string reason; 59*600f14f4SXin Li public: TargetException(const std::string r)60*600f14f4SXin Li TargetException(const std::string r) : ExceptionBase(), reason(r) { } what(void) const61*600f14f4SXin Li virtual const char* what(void) const throw() { 62*600f14f4SXin Li return reason.c_str(); 63*600f14f4SXin Li } 64*600f14f4SXin Li }; 65*600f14f4SXin Li 66*600f14f4SXin Li } /* namespace exception */ 67*600f14f4SXin Li } /* namespace fuzzing */ 68