AuroraRuntime/Include/Aurora/Debug/SysPanic.hpp

77 lines
1.8 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: SysPanic.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
2023-12-29 18:46:16 +00:00
namespace Aurora
{
AUKN_SYM bool RuntimeHasStarted();
}
2021-09-06 10:58:08 +00:00
#if defined(_AUHAS_FMT)
2021-06-27 21:25:29 +00:00
template<typename ... T>
static inline void AU_NORETURN SysPanic(fmt::format_string<T...> msg, T&& ... args)
2021-06-27 21:25:29 +00:00
{
2023-12-29 18:46:16 +00:00
if (Aurora::RuntimeHasStarted())
{
Aurora::Debug::AddMemoryCrunch();
try
{
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", msg, AuForward<T>(args)...);
}
catch (...)
2023-04-21 21:09:01 +00:00
{
2023-04-21 21:09:01 +00:00
}
}
2021-06-27 21:25:29 +00:00
Aurora::Debug::Panic();
2021-09-06 10:58:08 +00:00
}
template<typename ... T>
static inline void AU_NORETURN SysPanic2(AuUInt uLineHintInNonshipBinary,
fmt::format_string<T...> msg, T&& ... args)
{
2023-12-29 18:46:16 +00:00
if (Aurora::RuntimeHasStarted())
{
Aurora::Debug::AddMemoryCrunch();
try
{
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", msg, AuForward<T>(args)...);
}
catch (...)
2023-04-25 11:23:22 +00:00
{
2023-04-25 11:23:22 +00:00
}
}
Aurora::Debug::Panic2(uLineHintInNonshipBinary);
}
2023-04-21 21:09:01 +00:00
template<typename ... T>
static inline void AU_NORETURN SysPanic()
{
Aurora::Debug::Panic();
}
template<typename ... T>
static inline void AU_NORETURN SysPanic2(AuUInt uLineHintInNonshipBinary)
{
Aurora::Debug::Panic2(uLineHintInNonshipBinary);
}
static inline AU_NORETURN void SysPanic(const char *pMsg)
{
SysPanic("{}", pMsg);
}
2023-10-11 04:19:14 +00:00
static inline AU_NORETURN void SysUnreachable_(int uLineHintInNonshipBinary)
2023-04-21 21:09:01 +00:00
{
Aurora::Debug::Panic2(uLineHintInNonshipBinary);
}
#define SysUnreachable() SysUnreachable_(SysSafeLine)
2021-09-06 10:58:08 +00:00
#endif