2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
2021-04-06 02:10:14 +01:00
|
|
|
|
2023-08-13 15:47:51 +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)
|
2024-07-23 21:14:22 +01:00
|
|
|
, message(std::string{message})
|
2022-11-17 00:49:59 +00:00
|
|
|
{}
|
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;
|
|
|
|
|
}
|
2021-10-06 21:12:31 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
std::string message;
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
2021-06-22 23:52:31 +01:00
|
|
|
}
|