75 lines
1.5 KiB
C++
Executable File
75 lines
1.5 KiB
C++
Executable File
|
|
#pragma once
|
|
|
|
|
|
#include <exception>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace wfr {
|
|
namespace exception {
|
|
|
|
|
|
/**
|
|
* Exception base class.
|
|
*/
|
|
class wfr_exception : public std::exception {
|
|
protected:
|
|
const std::string message;
|
|
std::shared_ptr<std::exception> cause;
|
|
|
|
public:
|
|
wfr_exception(const std::string& message = "", std::shared_ptr<std::exception> cause = std::shared_ptr<std::exception>()) 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<std::exception> 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
|