Core/Error: Remove Directory include in Error.hpp
Former-commit-id: 61ed7168229dde265159fa5acde0c57c315b85fe
This commit is contained in:
parent
59ef4bc9b5
commit
1ec8c8c5e0
|
|
@ -8,20 +8,19 @@
|
||||||
#define NAZARA_ERROR_HPP
|
#define NAZARA_ERROR_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Enums.hpp>
|
|
||||||
#include <Nazara/Core/Config.hpp>
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Directory.hpp>
|
#include <Nazara/Core/Enums.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
|
|
||||||
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
||||||
#define NazaraAssert(a, err) if (!(a)) Nz::Error::Trigger(Nz::ErrorType_AssertFailed, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
#define NazaraAssert(a, err) if (!(a)) Nz::Error::Trigger(Nz::ErrorType_AssertFailed, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||||
#else
|
#else
|
||||||
#define NazaraAssert(a, err) for (;;) break
|
#define NazaraAssert(a, err) for (;;) break
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NazaraError(err) Nz::Error::Trigger(Nz::ErrorType_Normal, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
#define NazaraError(err) Nz::Error::Trigger(Nz::ErrorType_Normal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||||
#define NazaraInternalError(err) Nz::Error::Trigger(Nz::ErrorType_Internal, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
#define NazaraInternalError(err) Nz::Error::Trigger(Nz::ErrorType_Internal, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||||
#define NazaraWarning(err) Nz::Error::Trigger(Nz::ErrorType_Warning, err, __LINE__, Nz::Directory::GetCurrentFileRelativeToEngine(__FILE__), NAZARA_FUNCTION)
|
#define NazaraWarning(err) Nz::Error::Trigger(Nz::ErrorType_Warning, err, __LINE__, __FILE__, NAZARA_FUNCTION)
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <Nazara/Core/Directory.hpp>
|
||||||
#include <Nazara/Core/Log.hpp>
|
#include <Nazara/Core/Log.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
@ -87,12 +88,12 @@ namespace Nz
|
||||||
wchar_t* buffer = nullptr;
|
wchar_t* buffer = nullptr;
|
||||||
|
|
||||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
|
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
nullptr,
|
nullptr,
|
||||||
code,
|
code,
|
||||||
0,
|
0,
|
||||||
reinterpret_cast<LPWSTR>(&buffer),
|
reinterpret_cast<LPWSTR>(&buffer),
|
||||||
0,
|
0,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
String error(String::Unicode(buffer));
|
String error(String::Unicode(buffer));
|
||||||
LocalFree(buffer);
|
LocalFree(buffer);
|
||||||
|
|
@ -165,6 +166,8 @@ namespace Nz
|
||||||
|
|
||||||
void Error::Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function)
|
void Error::Trigger(ErrorType type, const String& error, unsigned int line, const char* file, const char* function)
|
||||||
{
|
{
|
||||||
|
file = Nz::Directory::GetCurrentFileRelativeToEngine(file);
|
||||||
|
|
||||||
if (type == ErrorType_AssertFailed || (s_flags & ErrorFlag_Silent) == 0 || (s_flags & ErrorFlag_SilentDisabled) != 0)
|
if (type == ErrorType_AssertFailed || (s_flags & ErrorFlag_Silent) == 0 || (s_flags & ErrorFlag_SilentDisabled) != 0)
|
||||||
Log::WriteError(type, error, line, file, function);
|
Log::WriteError(type, error, line, file, function);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue