Line data Source code
1 : /*! 2 : * \file 3 : * \brief Class tools::exception. 4 : */ 5 : #ifndef EXCEPTION_HPP_ 6 : #define EXCEPTION_HPP_ 7 : 8 : #include <exception> 9 : #include <string> 10 : #ifdef SPU_STACKTRACE 11 : #include <cpptrace/cpptrace.hpp> 12 : #endif 13 : 14 : namespace spu 15 : { 16 : namespace tools 17 : { 18 : #ifdef SPU_STACKTRACE 19 : class exception : public cpptrace::exception_with_message 20 : { 21 : #else 22 : class exception : public std::exception 23 : { 24 : #endif 25 : public: 26 : static bool no_stacktrace; 27 : 28 : private: 29 : #ifdef SPU_STACKTRACE 30 : mutable std::string what_string; 31 : #else 32 : std::string message; // the message only 33 : #endif 34 : 35 : public: 36 : exception() noexcept; 37 : explicit exception(std::string&& message) noexcept; 38 : exception(std::string&& filename, int&& line_num, std::string&& funcname = "", std::string&& message = "") noexcept; 39 : 40 0 : virtual ~exception() = default; 41 : 42 : const char* what() const noexcept override; // return the message and the back trace if enabled 43 : }; 44 : } 45 : } 46 : 47 : // include specific exceptions 48 : #include "Tools/Exception/cannot_allocate/cannot_allocate.hpp" 49 : #include "Tools/Exception/control_flow_error/control_flow_error.hpp" 50 : #include "Tools/Exception/domain_error/domain_error.hpp" 51 : #include "Tools/Exception/invalid_argument/invalid_argument.hpp" 52 : #include "Tools/Exception/length_error/length_error.hpp" 53 : #include "Tools/Exception/logic_error/logic_error.hpp" 54 : #include "Tools/Exception/out_of_range/out_of_range.hpp" 55 : #include "Tools/Exception/overflow_error/overflow_error.hpp" 56 : #include "Tools/Exception/processing_aborted/processing_aborted.hpp" 57 : #include "Tools/Exception/range_error/range_error.hpp" 58 : #include "Tools/Exception/runtime_error/runtime_error.hpp" 59 : #include "Tools/Exception/underflow_error/underflow_error.hpp" 60 : #include "Tools/Exception/unimplemented_error/unimplemented_error.hpp" 61 : #include "Tools/Exception/waiting_canceled/waiting_canceled.hpp" 62 : 63 : #endif /* EXCEPTION_HPP_ */