#pragma once #include #include #include namespace wfr { namespace exception { /** * Exception base class. */ class wfr_exception : public std::exception { protected: const std::string message; std::shared_ptr cause; public: wfr_exception(const std::string& message = "", std::shared_ptr cause = std::shared_ptr()) noexcept : message(message), cause(cause) {} wfr_exception(const wfr_exception& e) noexcept : message(e.message), cause(e.cause) {} virtual ~wfr_exception() noexcept {} virtual const std::string& getMessage() noexcept { return message; } virtual std::weak_ptr getCause() noexcept { return cause; } virtual const char* what() const noexcept override { return message.c_str(); }; }; /** * Represents a fatal error that results in program abortion **/ class wfr_fatal_error : public wfr_exception { public: using wfr_exception::wfr_exception; }; /** * Represents a not found exception. **/ class wfr_not_found : public wfr_exception { public: using wfr_exception::wfr_exception; }; /** * Represents a not found activity instance. **/ class wfr_missing_instance : public wfr_exception { public: using wfr_exception::wfr_exception; }; /** * Represents an illegal argument. **/ class wfr_illegal_argument : public wfr_exception { public: using wfr_exception::wfr_exception; }; } // namespace exception } // namespace wfr