Files
BloomPatched/src/Exceptions/Exception.hpp

35 lines
938 B
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
2021-04-04 21:04:12 +01:00
namespace Bloom::Exceptions
{
class Exception: public std::runtime_error
{
public:
2021-04-06 02:10:14 +01:00
explicit Exception(): std::runtime_error("") {}
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
2021-12-22 23:11:18 +00:00
explicit Exception(const std::string& message): std::runtime_error(message.c_str()), message(message) {}
2021-04-04 21:04:12 +01:00
2021-12-22 23:11:18 +00:00
explicit Exception(const char* message): std::runtime_error(message), message(std::string(message)) {}
2021-04-04 21:04:12 +01:00
const char* what() const noexcept override {
return this->message.c_str();
}
std::string getMessage() const {
return this->message;
}
protected:
std::string message;
2021-04-04 21:04:12 +01:00
};
}