77 lines
1.7 KiB
C++
77 lines
1.7 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;
|
|
|
|
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
|
|
{
|
|
AUKN_SYM ErrorStack();
|
|
AUKN_SYM ~ErrorStack();
|
|
|
|
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; |