2021-01-09 00:30:07 +07:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdexcept>
|
2021-05-27 15:51:00 +07:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
2021-01-09 00:30:07 +07:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
|
|
|
namespace Shader {
|
|
|
|
|
2021-05-27 15:51:00 +07:00
|
|
|
class Exception : public std::exception {
|
|
|
|
public:
|
2021-05-27 17:03:49 +07:00
|
|
|
explicit Exception(std::string message) noexcept : err_message{std::move(message)} {}
|
2021-05-27 15:51:00 +07:00
|
|
|
|
2021-05-27 17:03:49 +07:00
|
|
|
const char* what() const noexcept override {
|
|
|
|
return err_message.c_str();
|
2021-05-27 15:51:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Prepend(std::string_view prepend) {
|
2021-05-27 17:03:49 +07:00
|
|
|
err_message.insert(0, prepend);
|
2021-05-27 15:51:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Append(std::string_view append) {
|
2021-05-27 17:03:49 +07:00
|
|
|
err_message += append;
|
2021-05-27 15:51:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-05-27 17:03:49 +07:00
|
|
|
std::string err_message;
|
2021-05-27 15:51:00 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
class LogicError : public Exception {
|
2021-01-09 00:30:07 +07:00
|
|
|
public:
|
|
|
|
template <typename... Args>
|
|
|
|
LogicError(const char* message, Args&&... args)
|
2021-06-28 22:44:03 +07:00
|
|
|
: Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {}
|
2021-01-09 00:30:07 +07:00
|
|
|
};
|
|
|
|
|
2021-05-27 15:51:00 +07:00
|
|
|
class RuntimeError : public Exception {
|
2021-01-09 00:30:07 +07:00
|
|
|
public:
|
|
|
|
template <typename... Args>
|
|
|
|
RuntimeError(const char* message, Args&&... args)
|
2021-06-28 22:44:03 +07:00
|
|
|
: Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {}
|
2021-01-09 00:30:07 +07:00
|
|
|
};
|
|
|
|
|
2021-05-27 15:51:00 +07:00
|
|
|
class NotImplementedException : public Exception {
|
2021-01-09 00:30:07 +07:00
|
|
|
public:
|
|
|
|
template <typename... Args>
|
|
|
|
NotImplementedException(const char* message, Args&&... args)
|
2021-06-28 22:44:03 +07:00
|
|
|
: Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {
|
2021-05-27 15:51:00 +07:00
|
|
|
Append(" is not implemented");
|
|
|
|
}
|
2021-01-09 00:30:07 +07:00
|
|
|
};
|
|
|
|
|
2021-05-27 15:51:00 +07:00
|
|
|
class InvalidArgument : public Exception {
|
2021-01-09 00:30:07 +07:00
|
|
|
public:
|
|
|
|
template <typename... Args>
|
|
|
|
InvalidArgument(const char* message, Args&&... args)
|
2021-06-28 22:44:03 +07:00
|
|
|
: Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {}
|
2021-01-09 00:30:07 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Shader
|