AuroraRuntime/Include/Aurora/Debug/ErrorStack.hpp
Reece Wilson 1ff9feb303 [+] Initial heap stat counter API
[+] Upcoming failure categories
[+] Updated SysPushXXX prototypes
[*] Restore bandwidth OnTick position for extrapolate (using current frame stats, ref to last) fractional lerps into the future with ref to average
[*] Compression.cpp AuList<AuUInt8> upgrade was incomplete & could've been improved with modern apis
2022-12-08 19:34:15 +00:00

87 lines
1.9 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ErrorStack.hpp
Date: 2022-11-29
Author: Reece
***/
#pragma once
namespace Aurora::Debug
{
struct ErrorStack;
AUKN_SYM void PushStack(ErrorStack *pStack);
AUKN_SYM void PopStack(ErrorStack *pStack);
struct ErrorStackAccessor;
struct ThreadMessage
{
AuSPtr<ThreadMessage> pNextThreadMesage;
AuSPtr<AuString> pStringMessage;
AuOptional<EFailureCategory> eFailureCategory;
AuOptional<StackTrace> optStackTrace;
AuOptional<AuUInt> optOsErrorCode;
AuUInt16 uDebugBuildSourceLineHint {};
AUKN_SYM AuString ToString();
};
struct ErrorStack
{
inline ErrorStack()
{
PushStack(this);
}
inline ~ErrorStack()
{
PopStack(this);
}
inline bool HasCaptured()
{
CheckErrors();
return bool(this->pHead);
}
inline bool HasMultipleOccurred()
{
return this->HasCaptured() && bool(this->pHead->pNextThreadMesage);
}
inline StackTrace *ToStackTrace()
{
if (!this->HasCaptured())
{
return {};
}
if (!this->pHead->optStackTrace)
{
return {};
}
return &this->pHead->optStackTrace.value();
}
inline AuOptional<AuString> ToString()
{
return this->HasCaptured() ? this->pHead->ToString() : AuString {};
}
inline AuSPtr<ThreadMessage> FirstMessage()
{
return this->pHead;
}
protected:
AuSPtr<ThreadMessage> pHead;
ErrorStack *pNext {};
friend ErrorStackAccessor;
};
}
using AuErrorStack = Aurora::Debug::ErrorStack;