MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
HResultMacros.h File Reference
#include "CoreMinimal.h"
#include "McroWindows/Error/WindowsError.h"

Go to the source code of this file.

Macros

#define HR_WITH_STACKTRACE   ->WithCppStackTrace()
 
#define MCRO_TRY_WITH_IMPL(tempVar, expression, noErrorInfo)
 
#define HR_TRY_WITH(expression, noErrorInfo)
 Use this macro in a function which returns an Mcro::Error::TMaybe.
 
#define HR_TRY(expression)
 Use this macro in a function which returns an Mcro::Error::TMaybe. On non-shipping builds stacktrace is captured by default.
 
#define HR_TRY_FAST(expression)
 Use this macro in a function which returns an Mcro::Error::TMaybe. This version doesn't capture a stacktrace.
 
#define HR_TRY_RAW(expression)
 Use this macro in a function which returns an Mcro::Error::TMaybe. This version doesn't capture a stacktrace and it won't calculate human readable messages from the HRESULT the error code.
 

Detailed Description

Author
David Mórász
Date
2025

This header provides convenience macros for dealing with API returning HRESULT elegantly

Definition in file HResultMacros.h.

Macro Definition Documentation

◆ HR_TRY

#define HR_TRY ( expression)
Value:
HR_TRY_WITH(expression, false) \
->AsFatal() \
->BreakDebugger()
#define HR_TRY_WITH(expression, noErrorInfo)
Use this macro in a function which returns an Mcro::Error::TMaybe.
#define HR_WITH_STACKTRACE

Use this macro in a function which returns an Mcro::Error::TMaybe. On non-shipping builds stacktrace is captured by default.

Definition at line 45 of file HResultMacros.h.

◆ HR_TRY_FAST

#define HR_TRY_FAST ( expression)
Value:
HR_TRY_WITH(expression, false)

Use this macro in a function which returns an Mcro::Error::TMaybe. This version doesn't capture a stacktrace.

Definition at line 52 of file HResultMacros.h.

◆ HR_TRY_RAW

#define HR_TRY_RAW ( expression)
Value:
HR_TRY_WITH(expression, true)

Use this macro in a function which returns an Mcro::Error::TMaybe. This version doesn't capture a stacktrace and it won't calculate human readable messages from the HRESULT the error code.

Definition at line 59 of file HResultMacros.h.

◆ HR_TRY_WITH

#define HR_TRY_WITH ( expression,
noErrorInfo )
Value:
MCRO_TRY_WITH_IMPL(PREPROCESSOR_JOIN(tempHr, __LINE__), expression, noErrorInfo)
#define MCRO_TRY_WITH_IMPL(tempVar, expression, noErrorInfo)

Use this macro in a function which returns an Mcro::Error::TMaybe.

Definition at line 37 of file HResultMacros.h.

◆ HR_WITH_STACKTRACE

#define HR_WITH_STACKTRACE   ->WithCppStackTrace()

Definition at line 25 of file HResultMacros.h.

◆ MCRO_TRY_WITH_IMPL

#define MCRO_TRY_WITH_IMPL ( tempVar,
expression,
noErrorInfo )
Value:
HRESULT tempVar = (expression); \
if (UNLIKELY(tempVar != S_OK)) \
->WithLocation() \
->AsRecoverable \
->WithCodeContext(PREPROCESSOR_TO_TEXT(expression))
#define PREPROCESSOR_TO_TEXT(x)
Definition Macros.h:51
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
An error wrapping HRESULT code returned by many Microsoft APIs. It will also collect human readable m...

Definition at line 28 of file HResultMacros.h.