Added better debug

Now triggers a breakpoint when a function fails
This commit is contained in:
Pasha Bibko
2025-07-20 14:18:31 +01:00
parent 8f75e52a07
commit ac656b7b0f
5 changed files with 36 additions and 52 deletions

View File

@@ -1,13 +1,6 @@
#pragma once
// Platform specific includes //
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#error "Code is currently only supported on Win32"
#endif // _WIN32
#include <OS.h>
#include <iostream>
#include <ostream>

10
Common/OS.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
// Platform specific includes //
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#error "Code is currently only supported on Win32"
#endif // _WIN32

View File

@@ -1,5 +1,7 @@
#pragma once
#include <OS.h>
#include <type_traits>
#include <cstdlib>
@@ -11,6 +13,14 @@ namespace LXC::Util
explicit FunctionFail(ErrorType _err)
: error(_err)
{
// Only checks for a debugger when compiled in Debug mode //
#ifdef _DEBUG
// Triggers a breakpoint when a debugger is attached as a function has failed //
if (IsDebuggerPresent())
DebugBreak();
#endif
}
ErrorType error;