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)
 
#define HR_TRY(expression)
 
#define HR_TRY_FAST(expression)
 
#define HR_TRY_RAW(expression)
 

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)
#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 44 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 51 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 57 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:17
static TSharedRef< T > Make(T *newError, Args &&... args)
Definition Error.h:136

Definition at line 28 of file HResultMacros.h.