25#include "CoreMinimal.h"
28#include "Logging/LogMacros.h"
39 FString
const& codeContext,
40 bool async,
bool important,
41 TUniqueFunction<
void(
IErrorRef const&)>&& extraSetup,
42 std::source_location
const& location = std::source_location::current()
49#define MCRO_ASSERT_SUBMIT_ERROR(condition, severity, async, important, ...) \
50 Mcro::AssertMacros::Detail::SubmitError( \
51 Mcro::Error::EErrorSeverity::severity, \
52 PREPROCESSOR_TO_TEXT(condition), \
54 [&](Mcro::Error::IErrorRef const& error) { (error __VA_ARGS__); } \
57#define MCRO_ASSERT_CRASH_METHOD \
58 UE_LOG(LogTemp, Fatal, \
59 TEXT_"Program cannot continue for the reasons above. (at " \
60 PREPROCESSOR_TO_TEXT(__FILE__:__LINE__) TEXT_")" \
63#define MCRO_CRASH_BODY(condition, ...) \
64 MCRO_ASSERT_SUBMIT_ERROR( \
65 condition, Crashing, false, false, \
68 MCRO_ASSERT_CRASH_METHOD;
70#define MCRO_QUIT_BODY(condition, returnOnFailure, ...) \
71 MCRO_ASSERT_SUBMIT_ERROR( \
73 Mcro::AssertMacros::Detail::IsRunningPIE(), \
74 Mcro::AssertMacros::Detail::IsRunningPIE(), \
77 if (Mcro::AssertMacros::Detail::IsRunningPIE()) \
79 Mcro::AssertMacros::Detail::StopPie(); \
80 return returnOnFailure; \
82 else { MCRO_ASSERT_CRASH_METHOD }
84#define MCRO_ASSERT_CRASH_COMMON(condition, ...) \
85 if (UNLIKELY(!(condition))) \
87 MCRO_CRASH_BODY(condition, __VA_ARGS__) \
90#define MCRO_ASSERT_QUIT_COMMON(condition, returnOnFailure, ...) \
91 if (UNLIKELY(!(condition))) \
93 MCRO_QUIT_BODY(condition, returnOnFailure, __VA_ARGS__) \
114#define ASSERT_CRASH(condition, ...) MCRO_ASSERT_CRASH_COMMON(condition, __VA_ARGS__)
117#define FORCE_CRASH(...) MCRO_CRASH_BODY(Invalid code path, __VA_ARGS__)
148#define ASSERT_QUIT(condition, returnOnFailure, ...) MCRO_ASSERT_QUIT_COMMON(condition, returnOnFailure, __VA_ARGS__)
151#define FORCE_QUIT(returnOnFailure, ...) MCRO_QUIT_BODY(Invalid code path, returnOnFailure, __VA_ARGS__)
153#elif UE_BUILD_SHIPPING && defined(MCRO_ASSERT_IGNORE_SHIPPING)
155#define ASSERT_CRASH(condition, ...)
156#define ASSERT_QUIT(condition, returnOnFailure, ...)
157#define FORCE_CRASH(...)
161#define ASSERT_CRASH(condition, ...) MCRO_ASSERT_CRASH_COMMON(condition, __VA_ARGS__)
162#define ASSERT_QUIT(condition, returnOnFailure, ...) MCRO_ASSERT_CRASH_COMMON(condition, __VA_ARGS__)
163#define FORCE_CRASH(...) MCRO_CRASH_BODY(Invalid code path, __VA_ARGS__)
168#define ASSERT_QUIT_NON_ERROR(maybe, returnOnFailure, ...) ASSERT_QUIT(maybe, returnOnFailure, ->WithError(maybe.GetErrorRef()) __VA_ARGS__)
171#define ASSERT_CRASH_NON_ERROR(maybe, ...) ASSERT_CRASH(maybe, ->WithError(maybe.GetErrorRef()) __VA_ARGS__)
MCRO_API void SubmitError(EErrorSeverity severity, FString const &codeContext, bool async, bool important, TUniqueFunction< void(IErrorRef const &)> &&extraSetup, std::source_location const &location=std::source_location::current())
MCRO_API bool IsRunningPIE()
Do not use this namespace directly use ASSERT_QUIT|CRASH macros instead.
Contains utilities for structured error handling.
TSharedRef< IError > IErrorRef
Convenience alias for an instance of an error.
EErrorSeverity
Indicate the severity of an error and at what discretion the caller may treat it.