Files
BloomPatched/src/Exceptions/Exception.hpp

44 lines
1.0 KiB
C++
Raw Normal View History

2021-04-04 21:04:12 +01:00
#pragma once
#include <stdexcept>
2021-04-06 02:10:14 +01:00
namespace Exceptions
2021-04-04 21:04:12 +01:00
{
class Exception: public std::runtime_error
{
public:
2022-11-17 00:49:59 +00:00
explicit Exception()
: std::runtime_error("")
{}
explicit Exception(const std::string& message)
: std::runtime_error(message.c_str())
, message(message)
{}
2021-04-04 21:04:12 +01:00
2022-11-17 00:49:59 +00:00
explicit Exception(const char* message)
: std::runtime_error(message)
, message(std::string(message))
{}
2021-04-04 21:04:12 +01:00
2022-12-10 19:23:06 +00:00
virtual ~Exception() = default;
Exception(const Exception& other) noexcept = default;
Exception(Exception&& other) = default;
Exception& operator = (const Exception& other) = default;
Exception& operator = (Exception&& other) = default;
2021-04-04 21:04:12 +01:00
const char* what() const noexcept override {
return this->message.c_str();
}
2022-12-10 19:23:06 +00:00
const std::string& getMessage() const {
2021-04-04 21:04:12 +01:00
return this->message;
}
protected:
std::string message;
2021-04-04 21:04:12 +01:00
};
}