MCRO
C++23 utilities for Unreal Engine.
|
#include <Error.h>
Public Member Functions | |
FORCEINLINE decltype(InnerErrors) ::TRangedForIterator | begin () |
FORCEINLINE decltype(InnerErrors) ::TRangedForConstIterator | begin () const |
FORCEINLINE decltype(InnerErrors) ::TRangedForIterator | end () |
FORCEINLINE decltype(InnerErrors) ::TRangedForConstIterator | end () const |
void | Initialize () |
virtual void | SerializeYaml (YAML::Emitter &emitter, bool isRoot) const |
FString | ToString () const |
std::string | ToStringUtf8 () const |
FORCEINLINE EErrorSeverity | GetSeverity () const |
FORCEINLINE int32 | GetSeverityInt () const |
FORCEINLINE FString const & | GetMessage () const |
FORCEINLINE FString const & | GetDetails () const |
FORCEINLINE FString const & | GetCodeContext () const |
FORCEINLINE TMap< FString, IErrorRef > const & | GetInnerErrors () const |
FORCEINLINE int32 | GetInnerErrorCount () const |
TArray< FString > | GetErrorPropagation () const |
FString | GetErrorPropagationJoined () const |
FStringView | GetSeverityString () const |
virtual TSharedRef< SErrorDisplay > | CreateErrorWidget () |
template<typename Self > | |
SelfRef< Self > | WithMessage (this Self &&self, const FString &input, bool condition=true) |
template<typename Self , typename... FormatArgs> | |
SelfRef< Self > | WithMessageF (this Self &&self, const TCHAR *input, FormatArgs &&... fmtArgs) |
template<typename Self , typename... FormatArgs> | |
SelfRef< Self > | WithMessageFC (this Self &&self, bool condition, const TCHAR *input, FormatArgs &&... fmtArgs) |
template<typename Self > | |
SelfRef< Self > | WithSeverity (this Self &&self, EErrorSeverity input) |
template<typename Self > | |
SelfRef< Self > | AsRecoverable (this Self &&self) |
template<typename Self > | |
SelfRef< Self > | AsFatal (this Self &&self) |
template<typename Self > | |
SelfRef< Self > | AsCrashing (this Self &&self) |
template<typename Self > | |
SelfRef< Self > | WithDetails (this Self &&self, const FString &input, bool condition=true) |
template<typename Self , typename... FormatArgs> | |
SelfRef< Self > | WithDetailsF (this Self &&self, const TCHAR *input, FormatArgs &&... fmtArgs) |
template<typename Self , typename... FormatArgs> | |
SelfRef< Self > | WithDetailsFC (this Self &&self, bool condition, const TCHAR *input, FormatArgs &&... fmtArgs) |
template<typename Self > | |
SelfRef< Self > | WithCodeContext (this Self &&self, const FString &input, bool condition=true) |
template<typename Self , CError Error> | |
SelfRef< Self > | WithError (this Self &&self, const TSharedRef< Error > &input, bool condition=true) |
template<typename Self , CError Error> | |
SelfRef< Self > | WithError (this Self &&self, const FString &name, const TSharedRef< Error > &input, bool condition=true) |
template<typename Self > | |
SelfRef< Self > | WithErrors (this Self &&self, const TArray< TTuple< FString, IErrorRef > > &input, bool condition=true) |
template<typename Self , CError... Errors> | |
SelfRef< Self > | WithErrors (this Self &&self, const TSharedRef< Errors > &... errors) |
template<typename Self , CError... Errors> | |
SelfRef< Self > | WithErrors (this Self &&self, bool condition, const TSharedRef< Errors > &... errors) |
template<typename Self > | |
SelfRef< Self > | WithAppendix (this Self &&self, const FString &name, const FString &text, bool condition=true) |
template<typename Self , typename... FormatArgs> | |
SelfRef< Self > | WithAppendixF (this Self &&self, const FString &name, const TCHAR *text, FormatArgs &&... fmtArgs) |
template<typename Self , typename... FormatArgs> | |
SelfRef< Self > | WithAppendixFC (this Self &&self, bool condition, const FString &name, const TCHAR *text, FormatArgs &&... fmtArgs) |
template<typename Self > | |
SelfRef< Self > | Notify (this Self &&self, Observable::IState< IErrorPtr > &state) |
template<typename Self > | |
SelfRef< Self > | BreakDebugger (this Self &&self) |
template<typename Self > | |
SelfRef< Self > | WithCppStackTrace (this Self &&self, const FString &name={}, bool condition=true, int32 numAdditionalStackFramesToIgnore=0, bool fastWalk=!UE_BUILD_DEBUG) |
template<typename Self > | |
SelfRef< Self > | WithBlueprintStackTrace (this Self &&self, const FString &name={}, bool condition=true) |
template<typename Self > | |
SelfRef< Self > | WithLocation (this Self &&self, std::source_location location=std::source_location::current()) |
Public Member Functions inherited from Mcro::Types::IHaveType | |
virtual | ~IHaveType ()=default |
template<typename Self > | |
SelfRef< Self > | WithType (this Self &&self) |
FORCEINLINE FName const & | GetType () const |
template<typename Derived , typename Self > | |
TSharedPtr< Derived > | AsExactly (this Self &&self) |
Static Public Member Functions | |
template<CError T, typename... Args> requires CSharedInitializeable<T, Args...> | |
static TSharedRef< T > | Make (T *newError, Args &&... args) |
Protected Member Functions | |
virtual void | SerializeInnerErrors (YAML::Emitter &emitter) const |
virtual void | SerializeErrorPropagation (YAML::Emitter &emitter) const |
virtual void | AddError (const FString &name, const TSharedRef< IError > &error, const FString &typeOverride={}) |
virtual void | AddAppendix (const FString &name, const FString &text, const FString &type=TEXT("Appendix")) |
void | AddCppStackTrace (const FString &name, int32 numAdditionalStackFramesToIgnore, bool fastWalk) |
void | AddBlueprintStackTrace (const FString &name) |
virtual void | SerializeMembers (YAML::Emitter &emitter, bool isRoot) const |
virtual void | NotifyState (Observable::IState< IErrorPtr > &state) |
Protected Member Functions inherited from Mcro::Types::IHaveType | |
template<typename Self > | |
void | SetType (this Self &&self) |
Protected Attributes | |
TMap< FString, IErrorRef > | InnerErrors |
TArray< std::source_location > | ErrorPropagation |
EErrorSeverity | Severity = EErrorSeverity::ErrorComponent |
FString | Message |
FString | Details |
FString | CodeContext |
Protected Attributes inherited from Mcro::Types::IHaveType | |
FName | TypeName |
Additional Inherited Members | |
Public Types inherited from Mcro::Types::IHaveType | |
template<typename Self > | |
using | SelfRef = TSharedRef<std::decay_t<Self>> |
A base class for a structured error handling and reporting with modular architecture and fluent API.
IError::Make(new FMyError())
this ensures the minimal runtime reflection features.TValueOrError
template which allows API's to indicate that they can fail in some ways without the need to consult an external documentation. It gives the developer total freedom however of what the error can be, so on its own it does not solve the questions of what/when/how. TMaybe
with IError
can be a powerful tool in the developer's arsenal when creating a library. IError
can standardize a detailed and structured way of communicating errors without hindering call-site usage. It can also automate the method and the format of logging the (many times excessive amount of) information surrounding an error, or decide how it may be presented for the user.
|
protectedvirtual |
Add extra separate blocks of text in an ad-hoc fashion
|
protected |
|
protected |
|
protectedvirtual |
Override this method if inner errors added to current one needs special attention
Reimplemented in Mcro::Error::IPlainTextComponent.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Override this function to customize how an error is displaxed for the end-user
Reimplemented in Mcro::Error::FCppException, and Mcro::Error::IPlainTextComponent.
|
inline |
|
inline |
|
inline |
|
inline |
TArray< FString > Mcro::Error::IError::GetErrorPropagation | ( | ) | const |
Get a list of source locations where this error has been handled. This is not equivalent of stack-traces but rather a historical record of where this error was considered throughout the source code. Each item in this list is explicitly recorded via WithLocation
. The first item is the earliest consideration of this error.
FString Mcro::Error::IError::GetErrorPropagationJoined | ( | ) | const |
Same as GetErrorPropagation
but items are separated by new line.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
FStringView Mcro::Error::IError::GetSeverityString | ( | ) | const |
Get the error severity as an unreal string.
|
inline |
|
inlinestatic |
To ensure automatic type reflection use IError::Make instead of manually constructing error objects
T | Type of new error |
Args | Arguments for the new error initializer. |
newError | Pass the new object in as new FMyError(...) |
args | Arguments for the new error initializer. |
|
inline |
|
protectedvirtual |
|
protectedvirtual |
Override this method if error propagation history needs custom way of serialization
|
protectedvirtual |
Override this method if inner errors needs custom way of serialization
Reimplemented in Mcro::Error::IPlainTextComponent.
|
protectedvirtual |
Override this method if direct members should be serialized differently or extra members are added by derived errors.
Reimplemented in Mcro::Error::FCppException.
|
virtual |
Override this function to change the method how this error is entirely serialized into a YAML format
emitter | the YAML node into which the data of this error needs to be appended to |
isRoot | true when the top level error is being serialized |
Reimplemented in Mcro::Error::IPlainTextComponent.
FString Mcro::Error::IError::ToString | ( | ) | const |
Render this error as a string using the YAML representation
std::string Mcro::Error::IError::ToStringUtf8 | ( | ) | const |
Render this error as a std::string using the YAML representation
|
inline |
Add an extra plain text block inside inner errors
Self | Deducing this |
name | Name of the extra text block |
text | Value of the extra text block |
condition | Only add inner error when this condition is satisfied |
|
inline |
|
inline |
Add an extra plain text block inside inner errors
Self | Deducing this |
name | Name of the extra text block |
text | Value of the extra text block |
fmtArgs | format arguments |
condition | Only add inner error when this condition is satisfied |
|
inline |
|
inline |
If available write a source code context into the error directly displaying where this error has occured
Self | Deducing this |
self | Deduced this (not present in calling arguments) |
input | the source code context |
condition | Only add code context when this condition is satisfied |
|
inline |
|
inline |
Specify details for the error which may provide further context for the user or provide them reminders/suggestions
Self | Deducing this |
self | Deduced this (not present in calling arguments) |
input | the details text |
condition | Only add details when this condition is satisfied |
|
inline |
Specify formatted details for the error which may provide further context for the user or provide them reminders/suggestions
Self | Deducing this |
self | Deduced this (not present in calling arguments) |
input | the details text |
fmtArgs | format arguments |
|
inline |
Specify formatted details for the error which may provide further context for the user or provide them reminders/suggestions
Self | Deducing this |
self | Deduced this (not present in calling arguments) |
input | the details text |
condition | Only add details when this condition is satisfied |
fmtArgs | format arguments |
|
inline |
Add one inner error with specific name.
Self | Deducing this |
Error | Deduced type of the error |
self | Deduced this (not present in calling arguments) |
name | Optional name of the error. If it's empty only the type of the error will be used for ID |
input | Inner error |
condition | Only add inner error when this condition is satisfied |
|
inline |
Add a uniquely typed inner error.
Self | Deducing this |
Error | Deduced type of the error |
self | Deduced this (not present in calling arguments) |
input | Inner error |
condition | Only add inner error when this condition is satisfied |
|
inline |
|
inline |
Add multiple errors at once with optional names
Self | Deducing this |
input | An array of tuples with otional error name and the error itself |
condition | Only add errors when this condition is satisfied |
|
inline |
|
inline |
Allow the error to record the source locations it has been handled at compile time. For example this gives more information than stack-traces because it can also record where errors were handled between parallel threads.
Self | Deducing this |
location | The location this error is handled at. In 99% of cases this should be left at the default |
|
inline |
|
inline |
|
inline |
Specify formatted error message with a fluent API
Self | Deducing this |
self | Deduced this (not present in calling arguments) |
condition | Only add message when this condition is satisfied |
input | the message format |
fmtArgs | format arguments |
|
inline |
Specify severity with a fluent API
Self | Deducing this |
self | Deduced this (not present in calling arguments) |
input | the severity |
|
protected |
|
protected |
|
protected |