MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Error::IError Class Reference

A base class for a structured error handling and reporting with modular architecture and fluent API. More...

#include <Error.h>

Inheritance diagram for Mcro::Error::IError:
Mcro::Types::IHaveTypeShareable Mcro::Types::IHaveType Mcro::Error::FAssertion Mcro::Error::FCppException Mcro::Error::FUnavailable Mcro::Error::IPlainTextComponent Mcro::Windows::Error::FHresultError Mcro::Windows::Error::FLastError Mcro::Error::TCppException< Exception > Mcro::Error::FBlueprintStackTrace Mcro::Error::FCppStackTrace

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 ()
 This is an empty function so any IError can fulfill CSharedInitializeable without needing extra attention in derived classes. Simply hide this function with overloads in derived classes if they need to use TSharedFromThis for initialization.
 
virtual void SerializeYaml (YAML::Emitter &emitter) const
 Override this function to change the method how this error is entirely serialized into a YAML format.
 
FString ToString () const
 Render this error as a string using the YAML representation.
 
std::string ToStringUtf8 () const
 Render this error as a std::string using the YAML representation.
 
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
 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 GetErrorPropagationJoined () const
 Same as GetErrorPropagation but items are separated by new line.
 
FStringView GetSeverityString () const
 Get the error severity as an unreal string.
 
virtual TSharedRef< SErrorDisplayCreateErrorWidget ()
 Override this function to customize how an error is displaxed for the end-user.
 
template<typename Self >
SelfRef< Self > WithMessage (this Self &&self, const FString &input, bool condition=true)
 Specify error message with a fluent API.
 
template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > WithMessageF (this Self &&self, const TCHAR *input, FormatArgs &&... fmtArgs)
 Specify formatted error message with a fluent API.
 
template<typename Self , typename... FormatArgs>
SelfRef< Self > WithMessageFC (this Self &&self, bool condition, const TCHAR *input, FormatArgs &&... fmtArgs)
 Specify formatted error message with a fluent API.
 
template<typename Self >
SelfRef< Self > WithSeverity (this Self &&self, EErrorSeverity input)
 Specify severity with a fluent API.
 
template<typename Self >
SelfRef< Self > AsRecoverable (this Self &&self)
 Recoverable shorthand.
 
template<typename Self >
SelfRef< Self > AsFatal (this Self &&self)
 Fatal shorthand.
 
template<typename Self >
SelfRef< Self > AsCrashing (this Self &&self)
 Crashing shorthand.
 
template<typename Self >
SelfRef< Self > WithDetails (this Self &&self, const FString &input, bool condition=true)
 Specify details for the error which may provide further context for the user or provide them reminders/suggestions.
 
template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > WithDetailsF (this Self &&self, const TCHAR *input, FormatArgs &&... fmtArgs)
 Specify formatted details for the error which may provide further context for the user or provide them reminders/suggestions.
 
template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > WithDetailsFC (this Self &&self, bool condition, const TCHAR *input, FormatArgs &&... fmtArgs)
 Specify formatted details for the error which may provide further context for the user or provide them reminders/suggestions.
 
template<typename Self >
SelfRef< Self > WithCodeContext (this Self &&self, const FString &input, bool condition=true)
 If available write a source code context into the error directly displaying where this error has occured.
 
template<typename Self , CError Error>
SelfRef< Self > WithError (this Self &&self, const TSharedRef< Error > &input, bool condition=true)
 Add a uniquely typed inner error.
 
template<typename Self , CError Error>
SelfRef< Self > WithError (this Self &&self, const FString &name, const TSharedRef< Error > &input, bool condition=true)
 Add one inner error with specific name.
 
template<typename Self >
SelfRef< Self > WithErrors (this Self &&self, const TArray< TTuple< FString, IErrorRef > > &input, bool condition=true)
 Add multiple errors at once with optional names.
 
template<typename Self , CError... Errors>
SelfRef< Self > WithErrors (this Self &&self, const TSharedRef< Errors > &... errors)
 Add multiple errors at once.
 
template<typename Self , CError... Errors>
SelfRef< Self > WithErrors (this Self &&self, bool condition, const TSharedRef< Errors > &... errors)
 Add multiple errors at once.
 
template<typename Self >
SelfRef< Self > WithAppendix (this Self &&self, const FString &name, const FString &text, bool condition=true)
 Add an extra plain text block inside inner errors.
 
template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > WithAppendixF (this Self &&self, const FString &name, const TCHAR *text, FormatArgs &&... fmtArgs)
 Add an extra plain text block inside inner errors.
 
template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > WithAppendixFC (this Self &&self, bool condition, const FString &name, const TCHAR *text, FormatArgs &&... fmtArgs)
 Add an extra plain text block inside inner errors.
 
template<typename Self >
SelfRef< Self > Notify (this Self &&self, Observable::IState< IErrorPtr > &state)
 Notify an observable state about this error.
 
template<typename Self >
SelfRef< Self > BreakDebugger (this Self &&self)
 Break if a debugger is attached when this error is created.
 
template<typename Self >
SelfRef< Self > WithCppStackTrace (this Self &&self, const FString &name={}, bool condition=true, int32 numAdditionalStackFramesToIgnore=0, bool fastWalk=!UE_BUILD_DEBUG)
 Shorthand for adding the current C++ stacktrace to this error.
 
template<typename Self >
SelfRef< Self > WithBlueprintStackTrace (this Self &&self, const FString &name={}, bool condition=true)
 Shorthand for adding the current Blueprint stacktrace to this error.
 
template<typename Self >
SelfRef< Self > WithLocation (this Self &&self, std::source_location const &location=std::source_location::current())
 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.
 
template<typename Self >
SelfRef< Self > Report (this Self &&self, bool condition=true)
 Report this error to the global IError::OnErrorReported event once it is deemed "ready", so an issue tracking system can handle important error unintrusively. Make sure this is the last modification on the error. Only call it once no further information can be added and on the top-most main error in case of aggregate errors.
 
template<typename Self , CFunctionCompatible_ArgumentsDecay< void(SelfRef< Self >)> Function>
SelfRef< Self > AsOperandWith (this Self &&self, Function &&function)
 Call an arbitrary function with this error. Other than cases like invoking macros inline operating on errors (like the inline ERROR_LOG overload) this may have limited use.
 
- Public Member Functions inherited from Mcro::Types::IHaveType
virtual ~IHaveType ()=default
 
template<CSharedFromThis Self>
SelfRef< Self > WithType (this Self &&self)
 Fluent API for setting tpye for deferred initialization (for example in factory functions)
 
template<typename Self >
requires (!CSharedFromThis<Self>)
Self && WithType (this Self &&self)
 Fluent API for setting tpye for deferred initialization (for example in factory functions)
 
FORCEINLINE FType const & GetType () const
 
FORCEINLINE FName const & GetTypeFName () const
 
FORCEINLINE FString GetTypeString () const
 
template<typename Derived , CSharedFromThis Self>
TSharedPtr< Derived > As (this Self &&self)
 Dynamic casting of this object to a derived top-level type. Casting also works if inheritance is done through TInherit template.
 
template<typename Derived , typename Self >
requires (!CSharedFromThis<Self>)
Derived * As (this Self &&self)
 Dynamic casting of this object to a derived top-level type. Casting also works if inheritance is done through TInherit template.
 

Static Public Member Functions

template<CError T, typename... Args>
requires CSharedInitializeable<T, Args...>
static TSharedRef< T > Make (T *newError, Args &&... args)
 To ensure automatic type reflection use IError::Make instead of manually constructing error objects.
 
static auto OnErrorReported () -> TEventDelegate< void(IErrorRef)> &
 When Report is called on an error this event is triggered, allowing issue tracking systems to react on IError's which are deemed "ready".
 

Protected Member Functions

virtual void SerializeInnerErrors (YAML::Emitter &emitter) const
 Override this method if inner errors needs custom way of serialization.
 
virtual void SerializeErrorPropagation (YAML::Emitter &emitter) const
 Override this method if error propagation history needs custom way of serialization.
 
virtual void AddError (const FString &name, const TSharedRef< IError > &error, const FString &typeOverride={})
 Override this method if inner errors added to current one needs special attention.
 
virtual void AddAppendix (const FString &name, const FString &text, const FString &type=TEXT_"Appendix")
 Add extra separate blocks of text in an ad-hoc fashion.
 
void AddCppStackTrace (const FString &name, int32 numAdditionalStackFramesToIgnore, bool fastWalk)
 
void AddBlueprintStackTrace (const FString &name)
 
virtual void SerializeMembers (YAML::Emitter &emitter) const
 Override this method if direct members should be serialized differently or extra members are added by derived errors.
 
virtual void NotifyState (Observable::IState< IErrorPtr > &state)
 
- Protected Member Functions inherited from Mcro::Types::IHaveType
template<typename Self >
void SetType (this Self &&self)
 This function needs to be called on top level derived type for runtime reflection to work.
 

Protected Attributes

TMap< FString, IErrorRefInnerErrors
 
TArray< std::source_location > ErrorPropagation
 
EErrorSeverity Severity = EErrorSeverity::ErrorComponent
 
FString Message
 
FString Details
 
FString CodeContext
 
bool bIsRoot = false
 
- Protected Attributes inherited from Mcro::Types::IHaveType
FName TypeName
 
FType TypeInfo
 

Friends

auto operator<< (YAML::Emitter &emitter, IErrorRef const &error) -> YAML::Emitter &
 Overload append operator for YAML::Emitter.
 

Additional Inherited Members

- Public Types inherited from Mcro::Types::IHaveType
template<typename Self >
using SelfRef = TSharedRef<std::decay_t<Self>>
 

Detailed Description

A base class for a structured error handling and reporting with modular architecture and fluent API.

Important
Instantiate errors only with IError::Make(new FMyError()) this ensures the minimal runtime reflection features.

Many times runtime errors are unavoidable and if an API only gives indication of success or failure (let's say in the form of a boolean) that will be quite frustrating for the user to report, as it gives no direction of course what went wrong, how it went wrong, and when it went wrong. Slightly better when the API gives a list of things what can go wrong and return an item from that list when things go wrong. This of course still doesn't allow to provide much of a context for the user.

An 'improvement' to that is using C++ exceptions, however it is not unanimously well received in the community because it can hide the fact that the API can bail on its caller. So when exceptions are enabled one may call every function of an API like if they were walking on a minefield. For this (and a couple more) reasons C++ exceptions are disabled by default in Unreal projects and viewed as terrible practice to introduce it ourselves.

Unreal does provide though the 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.

Using 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.

Definition at line 67 of file Error.h.

Member Function Documentation

◆ AddAppendix()

virtual void Mcro::Error::IError::AddAppendix ( const FString & name,
const FString & text,
const FString & type = TEXT_"Appendix" )
protectedvirtual

Add extra separate blocks of text in an ad-hoc fashion.

◆ AddBlueprintStackTrace()

void Mcro::Error::IError::AddBlueprintStackTrace ( const FString & name)
protected

◆ AddCppStackTrace()

void Mcro::Error::IError::AddCppStackTrace ( const FString & name,
int32 numAdditionalStackFramesToIgnore,
bool fastWalk )
protected

◆ AddError()

virtual void Mcro::Error::IError::AddError ( const FString & name,
const TSharedRef< IError > & error,
const FString & typeOverride = {} )
protectedvirtual

Override this method if inner errors added to current one needs special attention.

Reimplemented in Mcro::Error::IPlainTextComponent.

◆ AsCrashing()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::AsCrashing ( this Self && self)
inline

Crashing shorthand.

Definition at line 266 of file Error.h.

◆ AsFatal()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::AsFatal ( this Self && self)
inline

Fatal shorthand.

Definition at line 258 of file Error.h.

◆ AsOperandWith()

template<typename Self , CFunctionCompatible_ArgumentsDecay< void(SelfRef< Self >)> Function>
SelfRef< Self > Mcro::Error::IError::AsOperandWith ( this Self && self,
Function && function )
inline

Call an arbitrary function with this error. Other than cases like invoking macros inline operating on errors (like the inline ERROR_LOG overload) this may have limited use.

Template Parameters
SelfDeducing this.
FunctionFunction to call with this error.
Parameters
selfDeducing this.
functionFunction to call with this error.
Returns
Self for further fluent API setup

Definition at line 559 of file Error.h.

◆ AsRecoverable()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::AsRecoverable ( this Self && self)
inline

Recoverable shorthand.

Definition at line 250 of file Error.h.

◆ begin() [1/2]

FORCEINLINE decltype(InnerErrors) ::TRangedForIterator Mcro::Error::IError::begin ( )
inline

Definition at line 104 of file Error.h.

◆ begin() [2/2]

FORCEINLINE decltype(InnerErrors) ::TRangedForConstIterator Mcro::Error::IError::begin ( ) const
inline

Definition at line 105 of file Error.h.

◆ BreakDebugger()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::BreakDebugger ( this Self && self)
inline

Break if a debugger is attached when this error is created.

Definition at line 479 of file Error.h.

◆ CreateErrorWidget()

virtual TSharedRef< SErrorDisplay > Mcro::Error::IError::CreateErrorWidget ( )
virtual

Override this function to customize how an error is displaxed for the end-user.

Reimplemented in Mcro::Error::FCppException, and Mcro::Error::IPlainTextComponent.

◆ end() [1/2]

FORCEINLINE decltype(InnerErrors) ::TRangedForIterator Mcro::Error::IError::end ( )
inline

Definition at line 106 of file Error.h.

◆ end() [2/2]

FORCEINLINE decltype(InnerErrors) ::TRangedForConstIterator Mcro::Error::IError::end ( ) const
inline

Definition at line 107 of file Error.h.

◆ GetCodeContext()

FORCEINLINE FString const & Mcro::Error::IError::GetCodeContext ( ) const
inline

Definition at line 166 of file Error.h.

◆ GetDetails()

FORCEINLINE FString const & Mcro::Error::IError::GetDetails ( ) const
inline

Definition at line 165 of file Error.h.

◆ GetErrorPropagation()

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.

◆ GetErrorPropagationJoined()

FString Mcro::Error::IError::GetErrorPropagationJoined ( ) const

Same as GetErrorPropagation but items are separated by new line.

◆ GetInnerErrorCount()

FORCEINLINE int32 Mcro::Error::IError::GetInnerErrorCount ( ) const
inline

Definition at line 168 of file Error.h.

◆ GetInnerErrors()

FORCEINLINE TMap< FString, IErrorRef > const & Mcro::Error::IError::GetInnerErrors ( ) const
inline

Definition at line 167 of file Error.h.

◆ GetMessage()

FORCEINLINE FString const & Mcro::Error::IError::GetMessage ( ) const
inline

Definition at line 164 of file Error.h.

◆ GetSeverity()

FORCEINLINE EErrorSeverity Mcro::Error::IError::GetSeverity ( ) const
inline

Definition at line 162 of file Error.h.

◆ GetSeverityInt()

FORCEINLINE int32 Mcro::Error::IError::GetSeverityInt ( ) const
inline

Definition at line 163 of file Error.h.

◆ GetSeverityString()

FStringView Mcro::Error::IError::GetSeverityString ( ) const

Get the error severity as an unreal string.

◆ Initialize()

void Mcro::Error::IError::Initialize ( )
inline

This is an empty function so any IError can fulfill CSharedInitializeable without needing extra attention in derived classes. Simply hide this function with overloads in derived classes if they need to use TSharedFromThis for initialization.

Definition at line 115 of file Error.h.

◆ Make()

template<CError T, typename... Args>
requires CSharedInitializeable<T, Args...>
static TSharedRef< T > Mcro::Error::IError::Make ( T * newError,
Args &&... args )
inlinestatic

To ensure automatic type reflection use IError::Make instead of manually constructing error objects.

IError::Make(new FMyError(myConstructorArgs), myInitializerArgs);
static TSharedRef< T > Make(T *newError, Args &&... args)
To ensure automatic type reflection use IError::Make instead of manually constructing error objects.
Definition Error.h:148
Template Parameters
TType of new error
ArgsArguments for the new error initializer.
Parameters
newErrorPass the new object in as new FMyError(...)
argsArguments for the new error initializer.

Definition at line 148 of file Error.h.

◆ Notify()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::Notify ( this Self && self,
Observable::IState< IErrorPtr > & state )
inline

Notify an observable state about this error.

Definition at line 471 of file Error.h.

◆ NotifyState()

virtual void Mcro::Error::IError::NotifyState ( Observable::IState< IErrorPtr > & state)
protectedvirtual

◆ OnErrorReported()

static auto Mcro::Error::IError::OnErrorReported ( ) -> TEventDelegate< void(IErrorRef)> &
static

When Report is called on an error this event is triggered, allowing issue tracking systems to react on IError's which are deemed "ready".

ERROR_LOG, ERROR_CLOG and FErrorManager::DisplayError automatically report their input error.

◆ Report()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::Report ( this Self && self,
bool condition = true )
inline

Report this error to the global IError::OnErrorReported event once it is deemed "ready", so an issue tracking system can handle important error unintrusively. Make sure this is the last modification on the error. Only call it once no further information can be added and on the top-most main error in case of aggregate errors.

Template Parameters
SelfDeducing this
Parameters
conditionOnly report errors when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 536 of file Error.h.

◆ SerializeErrorPropagation()

virtual void Mcro::Error::IError::SerializeErrorPropagation ( YAML::Emitter & emitter) const
protectedvirtual

Override this method if error propagation history needs custom way of serialization.

◆ SerializeInnerErrors()

virtual void Mcro::Error::IError::SerializeInnerErrors ( YAML::Emitter & emitter) const
protectedvirtual

Override this method if inner errors needs custom way of serialization.

Reimplemented in Mcro::Error::IPlainTextComponent.

◆ SerializeMembers()

virtual void Mcro::Error::IError::SerializeMembers ( YAML::Emitter & emitter) const
protectedvirtual

Override this method if direct members should be serialized differently or extra members are added by derived errors.

Reimplemented in Mcro::Error::FCppException.

◆ SerializeYaml()

virtual void Mcro::Error::IError::SerializeYaml ( YAML::Emitter & emitter) const
virtual

Override this function to change the method how this error is entirely serialized into a YAML format.

Parameters
emitterthe YAML node into which the data of this error needs to be appended to

Reimplemented in Mcro::Error::IPlainTextComponent.

◆ ToString()

FString Mcro::Error::IError::ToString ( ) const

Render this error as a string using the YAML representation.

◆ ToStringUtf8()

std::string Mcro::Error::IError::ToStringUtf8 ( ) const

Render this error as a std::string using the YAML representation.

◆ WithAppendix()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithAppendix ( this Self && self,
const FString & name,
const FString & text,
bool condition = true )
inline

Add an extra plain text block inside inner errors.

Template Parameters
SelfDeducing this
Parameters
nameName of the extra text block
textValue of the extra text block
conditionOnly add inner error when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 431 of file Error.h.

◆ WithAppendixF()

template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > Mcro::Error::IError::WithAppendixF ( this Self && self,
const FString & name,
const TCHAR * text,
FormatArgs &&... fmtArgs )
inline

Add an extra plain text block inside inner errors.

Template Parameters
SelfDeducing this
Parameters
nameName of the extra text block
textValue of the extra text block
fmtArgsordered format arguments
Returns
Self for further fluent API setup

Definition at line 446 of file Error.h.

◆ WithAppendixFC()

template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > Mcro::Error::IError::WithAppendixFC ( this Self && self,
bool condition,
const FString & name,
const TCHAR * text,
FormatArgs &&... fmtArgs )
inline

Add an extra plain text block inside inner errors.

Template Parameters
SelfDeducing this
Parameters
nameName of the extra text block
textValue of the extra text block
fmtArgsordered format arguments
conditionOnly add inner error when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 462 of file Error.h.

◆ WithBlueprintStackTrace()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithBlueprintStackTrace ( this Self && self,
const FString & name = {},
bool condition = true )
inline

Shorthand for adding the current Blueprint stacktrace to this error.

Definition at line 498 of file Error.h.

◆ WithCodeContext()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithCodeContext ( this Self && self,
const FString & input,
bool condition = true )
inline

If available write a source code context into the error directly displaying where this error has occured.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe source code context
conditionOnly add code context when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 336 of file Error.h.

◆ WithCppStackTrace()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithCppStackTrace ( this Self && self,
const FString & name = {},
bool condition = true,
int32 numAdditionalStackFramesToIgnore = 0,
bool fastWalk = !UE_BUILD_DEBUG )
inline

Shorthand for adding the current C++ stacktrace to this error.

Definition at line 487 of file Error.h.

◆ WithDetails()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithDetails ( this Self && self,
const FString & input,
bool condition = true )
inline

Specify details for the error which may provide further context for the user or provide them reminders/suggestions.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe details text
conditionOnly add details when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 284 of file Error.h.

◆ WithDetailsF()

template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > Mcro::Error::IError::WithDetailsF ( this Self && self,
const TCHAR * input,
FormatArgs &&... fmtArgs )
inline

Specify formatted details for the error which may provide further context for the user or provide them reminders/suggestions.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe details text
fmtArgsordered format arguments
Returns
Self for further fluent API setup

Definition at line 302 of file Error.h.

◆ WithDetailsFC()

template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > Mcro::Error::IError::WithDetailsFC ( this Self && self,
bool condition,
const TCHAR * input,
FormatArgs &&... fmtArgs )
inline

Specify formatted details for the error which may provide further context for the user or provide them reminders/suggestions.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe details text
conditionOnly add details when this condition is satisfied
fmtArgsordered format arguments
Returns
Self for further fluent API setup

Definition at line 321 of file Error.h.

◆ WithError() [1/2]

template<typename Self , CError Error>
SelfRef< Self > Mcro::Error::IError::WithError ( this Self && self,
const FString & name,
const TSharedRef< Error > & input,
bool condition = true )
inline

Add one inner error with specific name.

Template Parameters
SelfDeducing this
ErrorDeduced type of the error
Parameters
selfDeduced this (not present in calling arguments)
nameOptional name of the error. If it's empty only the type of the error will be used for ID
inputInner error
conditionOnly add inner error when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 369 of file Error.h.

◆ WithError() [2/2]

template<typename Self , CError Error>
SelfRef< Self > Mcro::Error::IError::WithError ( this Self && self,
const TSharedRef< Error > & input,
bool condition = true )
inline

Add a uniquely typed inner error.

Template Parameters
SelfDeducing this
ErrorDeduced type of the error
Parameters
selfDeduced this (not present in calling arguments)
inputInner error
conditionOnly add inner error when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 352 of file Error.h.

◆ WithErrors() [1/3]

template<typename Self , CError... Errors>
SelfRef< Self > Mcro::Error::IError::WithErrors ( this Self && self,
bool condition,
const TSharedRef< Errors > &... errors )
inline

Add multiple errors at once.

Template Parameters
SelfDeducing this
ErrorsDeduced type of the errors
Parameters
errorsErrors to be added
conditionOnly add errors when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 416 of file Error.h.

◆ WithErrors() [2/3]

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithErrors ( this Self && self,
const TArray< TTuple< FString, IErrorRef > > & input,
bool condition = true )
inline

Add multiple errors at once with optional names.

Template Parameters
SelfDeducing this
Parameters
inputAn array of tuples with otional error name and the error itself
conditionOnly add errors when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 383 of file Error.h.

◆ WithErrors() [3/3]

template<typename Self , CError... Errors>
SelfRef< Self > Mcro::Error::IError::WithErrors ( this Self && self,
const TSharedRef< Errors > &... errors )
inline

Add multiple errors at once.

Template Parameters
SelfDeducing this
ErrorsDeduced type of the errors
Parameters
errorsErrors to be added
Returns
Self for further fluent API setup

Definition at line 401 of file Error.h.

◆ WithLocation()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithLocation ( this Self && self,
std::source_location const & location = std::source_location::current() )
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.

Template Parameters
SelfDeducing this
Parameters
locationThe location this error is handled at. In 99% of cases this should be left at the default
Returns
Self for further fluent API setup

Definition at line 518 of file Error.h.

◆ WithMessage()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithMessage ( this Self && self,
const FString & input,
bool condition = true )
inline

Specify error message with a fluent API.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe message
conditionOnly add message when this condition is satisfied
Returns
Self for further fluent API setup

Definition at line 196 of file Error.h.

◆ WithMessageF()

template<typename Self , CStringFormatArgument... FormatArgs>
SelfRef< Self > Mcro::Error::IError::WithMessageF ( this Self && self,
const TCHAR * input,
FormatArgs &&... fmtArgs )
inline

Specify formatted error message with a fluent API.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe message format
fmtArgsordered format arguments
Returns
Self for further fluent API setup

Definition at line 211 of file Error.h.

◆ WithMessageFC()

template<typename Self , typename... FormatArgs>
SelfRef< Self > Mcro::Error::IError::WithMessageFC ( this Self && self,
bool condition,
const TCHAR * input,
FormatArgs &&... fmtArgs )
inline

Specify formatted error message with a fluent API.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
conditionOnly add message when this condition is satisfied
inputthe message format
fmtArgsformat arguments
Returns
Self for further fluent API setup

Definition at line 227 of file Error.h.

◆ WithSeverity()

template<typename Self >
SelfRef< Self > Mcro::Error::IError::WithSeverity ( this Self && self,
EErrorSeverity input )
inline

Specify severity with a fluent API.

Template Parameters
SelfDeducing this
Parameters
selfDeduced this (not present in calling arguments)
inputthe severity
Returns
Self for further fluent API setup
See also
EErrorSeverity

Definition at line 242 of file Error.h.

Friends And Related Symbol Documentation

◆ operator<<

auto operator<< ( YAML::Emitter & emitter,
IErrorRef const & error ) -> YAML::Emitter &
friend

Overload append operator for YAML::Emitter.

Field Documentation

◆ bIsRoot

bool Mcro::Error::IError::bIsRoot = false
mutableprotected

Definition at line 76 of file Error.h.

◆ CodeContext

FString Mcro::Error::IError::CodeContext
protected

Definition at line 75 of file Error.h.

◆ Details

FString Mcro::Error::IError::Details
protected

Definition at line 74 of file Error.h.

◆ ErrorPropagation

TArray<std::source_location> Mcro::Error::IError::ErrorPropagation
protected

Definition at line 71 of file Error.h.

◆ InnerErrors

TMap<FString, IErrorRef> Mcro::Error::IError::InnerErrors
protected

Definition at line 70 of file Error.h.

◆ Message

FString Mcro::Error::IError::Message
protected

Definition at line 73 of file Error.h.

◆ Severity

EErrorSeverity Mcro::Error::IError::Severity = EErrorSeverity::ErrorComponent
protected

Definition at line 72 of file Error.h.


The documentation for this class was generated from the following file: