Fixed assertions handling
An assertion will now either abort the program or throw an exception Former-commit-id: ee221e0934aeb7fbf625d0c891f828ce497ac720
This commit is contained in:
parent
c9db44f85c
commit
fb68bf3a79
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
void NzError::Error(nzErrorType type, const NzString& error)
|
void NzError::Error(nzErrorType type, const NzString& error)
|
||||||
{
|
{
|
||||||
if ((s_flags & nzErrorFlag_Silent) == 0 || (s_flags & nzErrorFlag_SilentDisabled) != 0)
|
if (type == nzErrorType_AssertFailed || (s_flags & nzErrorFlag_Silent) == 0 || (s_flags & nzErrorFlag_SilentDisabled) != 0)
|
||||||
NazaraLog->WriteError(type, error);
|
NazaraLog->WriteError(type, error);
|
||||||
|
|
||||||
s_lastError = error;
|
s_lastError = error;
|
||||||
|
|
@ -27,16 +27,17 @@ void NzError::Error(nzErrorType type, const NzString& error)
|
||||||
|
|
||||||
#if NAZARA_CORE_EXIT_ON_ASSERT_FAILURE
|
#if NAZARA_CORE_EXIT_ON_ASSERT_FAILURE
|
||||||
if (type == nzErrorType_AssertFailed)
|
if (type == nzErrorType_AssertFailed)
|
||||||
std::exit(EXIT_FAILURE);
|
std::abort();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (type != nzErrorType_Warning && (s_flags & nzErrorFlag_ThrowException) != 0 && (s_flags & nzErrorFlag_ThrowExceptionDisabled) == 0)
|
if (type == nzErrorType_AssertFailed || (type != nzErrorType_Warning &&
|
||||||
|
(s_flags & nzErrorFlag_ThrowException) != 0 && (s_flags & nzErrorFlag_ThrowExceptionDisabled) == 0))
|
||||||
throw std::runtime_error(error);
|
throw std::runtime_error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzError::Error(nzErrorType type, const NzString& error, unsigned int line, const char* file, const char* function)
|
void NzError::Error(nzErrorType type, const NzString& error, unsigned int line, const char* file, const char* function)
|
||||||
{
|
{
|
||||||
if ((s_flags & nzErrorFlag_Silent) == 0 || (s_flags & nzErrorFlag_SilentDisabled) != 0)
|
if (type == nzErrorType_AssertFailed || (s_flags & nzErrorFlag_Silent) == 0 || (s_flags & nzErrorFlag_SilentDisabled) != 0)
|
||||||
NazaraLog->WriteError(type, error, line, file, function);
|
NazaraLog->WriteError(type, error, line, file, function);
|
||||||
|
|
||||||
s_lastError = error;
|
s_lastError = error;
|
||||||
|
|
@ -44,13 +45,14 @@ void NzError::Error(nzErrorType type, const NzString& error, unsigned int line,
|
||||||
s_lastErrorFunction = function;
|
s_lastErrorFunction = function;
|
||||||
s_lastErrorLine = line;
|
s_lastErrorLine = line;
|
||||||
|
|
||||||
if (type != nzErrorType_Warning && (s_flags & nzErrorFlag_ThrowException) != 0 && (s_flags & nzErrorFlag_ThrowExceptionDisabled) == 0)
|
|
||||||
throw std::runtime_error(error);
|
|
||||||
|
|
||||||
#if NAZARA_CORE_EXIT_ON_ASSERT_FAILURE
|
#if NAZARA_CORE_EXIT_ON_ASSERT_FAILURE
|
||||||
if (type == nzErrorType_AssertFailed)
|
if (type == nzErrorType_AssertFailed)
|
||||||
std::exit(EXIT_FAILURE);
|
std::abort();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (type == nzErrorType_AssertFailed || (type != nzErrorType_Warning &&
|
||||||
|
(s_flags & nzErrorFlag_ThrowException) != 0 && (s_flags & nzErrorFlag_ThrowExceptionDisabled) == 0))
|
||||||
|
throw std::runtime_error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
nzUInt32 NzError::GetFlags()
|
nzUInt32 NzError::GetFlags()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue