1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Implementa Exception

This commit is contained in:
Danilo 2024-06-22 10:11:31 -03:00
parent 8007a41690
commit b442c158b7
4 changed files with 40 additions and 0 deletions

View File

@ -2,6 +2,7 @@
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)
set(CMAKE_CXX_STANDARD 20)
# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)

37
inc/xna/exception.hpp Normal file
View File

@ -0,0 +1,37 @@
#ifndef XNA_EXCEPTION_HPP
#define XNA_EXCEPTION_HPP
#include <stdexcept>
#include <string>
#include <source_location>
namespace xna {
struct ExMessage {
inline static const std::string InitializeComponent = "Unable to initialize component";
};
struct Exception {
static void Throw(std::string const& message, const std::source_location location = std::source_location::current()) {
std::string error;
error.append("Exception in: ");
#if _DEBUG
error.append(location.file_name());
error.append("(");
error.append(std::to_string(location.line()));
error.append(":");
error.append(std::to_string(location.column()));
error.append(") ");
#endif
error.append("'");
error.append(location.function_name());
error.append("': ");
error.append(message);
error.append("\n");
throw std::runtime_error(error);
}
};
}
#endif

View File

@ -59,6 +59,7 @@ using comptr = Microsoft::WRL::ComPtr<T>;
// OTHERS INCLUDES
//--------------------------------//
#include "../exception.hpp"
#include "../graphics/blendstate.hpp"
#include "../graphics/adapter.hpp"
#include "../graphics/device.hpp"

View File

@ -3,6 +3,7 @@
#include "types.hpp"
#include "helpers.hpp"
#include "enums.hpp"
#include "exception.hpp"
#include "audio/audioengine.hpp"
#include "audio/soundeffect.hpp"
#include "common/color.hpp"