![]() |
MCRO
C++23 utilities for Unreal Engine.
|
#include "CoreMinimal.h"
#include "Mcro/Error.h"
#include "Mcro/Macros.h"
#include "Logging/LogMacros.h"
Go to the source code of this file.
Namespaces | |
namespace | Mcro |
namespace | Mcro::AssertMacros |
Do not use this namespace directly use ASSERT_QUIT|CRASH macros instead. | |
namespace | Mcro::AssertMacros::Detail |
Macros | |
#define | MCRO_ASSERT_SUBMIT_ERROR(condition, severity, async, important, ...) |
#define | MCRO_ASSERT_CRASH_METHOD |
#define | MCRO_CRASH_BODY(condition, ...) |
#define | MCRO_QUIT_BODY(condition, returnOnFailure, ...) |
#define | MCRO_ASSERT_CRASH_COMMON(condition, ...) |
#define | MCRO_ASSERT_QUIT_COMMON(condition, returnOnFailure, ...) |
#define | ASSERT_CRASH(condition, ...) |
Use this instead of check macro if the checked expression shouldn't be ignored in shipping builds. This version will also crash the entire editor even during a PIE session. Use this only if there's absolutely no way to recover from an invalid state, like a situation when early return is not possible / doesn't make sense (e.g.: return a checked pointer by reference). | |
#define | FORCE_CRASH(...) |
This is equivalent to ASSERT_CRASH but if a code path reaches this macro it will always crash. | |
#define | ASSERT_QUIT(condition, returnOnFailure, ...) |
Use this instead of check macro if the checked expression shouldn't be ignored in shipping builds. This version will not crash the editor but will display an error, stops the PIE, and should return the calling function. | |
#define | FORCE_QUIT(returnOnFailure, ...) |
This is equivalent to ASSERT_QUIT but if a code path reaches this macro it will always quit. | |
#define | ASSERT_QUIT_NON_ERROR(maybe, returnOnFailure, ...) |
Shorthand of ASSERT_QUIT for TMaybe monads. | |
#define | ASSERT_CRASH_NON_ERROR(maybe, ...) |
Shorthand of ASSERT_CRASH for TMaybe monads. | |
Functions | |
MCRO_API void | Mcro::AssertMacros::Detail::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 | Mcro::AssertMacros::Detail::IsRunningPIE () |
MCRO_API void | Mcro::AssertMacros::Detail::StopPie () |
By default ASSERT_QUIT|CRASH
macros are also active in Shipping builds. This was a personal preference and that's why you can turn it off if you define MCRO_ASSERT_IGNORE_SHIPPING
.
Definition in file AssertMacros.h.
#define ASSERT_CRASH | ( | condition, | |
... ) |
Use this instead of check
macro if the checked expression shouldn't be ignored in shipping builds. This version will also crash the entire editor even during a PIE session. Use this only if there's absolutely no way to recover from an invalid state, like a situation when early return is not possible / doesn't make sense (e.g.: return a checked pointer by reference).
This macro will attempt to display the error before crashing via the IError type. You can also append extra information to it, or even override preset information like so:
Definition at line 114 of file AssertMacros.h.
#define ASSERT_CRASH_NON_ERROR | ( | maybe, | |
... ) |
Shorthand of ASSERT_CRASH
for TMaybe monads.
Definition at line 169 of file AssertMacros.h.
#define ASSERT_QUIT | ( | condition, | |
returnOnFailure, | |||
... ) |
Use this instead of check
macro if the checked expression shouldn't be ignored in shipping builds. This version will not crash the editor but will display an error, stops the PIE, and should return the calling function.
A return value should be provided on failure, or leave it empty to return void. so either
This is done in the hopes that these checks failing in PIE sessions doesn't crash the entire editor giving the developer a chance for fixing the error before restarting. However, early returns might cause undefined/vaguely-defined side effects and may lead to uninitialized resources or in worst case scenario may lead to incorrect states in resource cleanups which then might crash the editor. Always check the validity of your resources in destructors. Failing this check outside of PIE or in a Standalone session will still crash with a check
macro.
This macro will attempt to display the error before quitting via the IError type. You can also append extra information to it like so, or even override preset information like so:
Definition at line 148 of file AssertMacros.h.
#define ASSERT_QUIT_NON_ERROR | ( | maybe, | |
returnOnFailure, | |||
... ) |
Shorthand of ASSERT_QUIT
for TMaybe monads.
Definition at line 166 of file AssertMacros.h.
#define FORCE_CRASH | ( | ... | ) |
This is equivalent to ASSERT_CRASH but if a code path reaches this macro it will always crash.
Definition at line 117 of file AssertMacros.h.
#define FORCE_QUIT | ( | returnOnFailure, | |
... ) |
This is equivalent to ASSERT_QUIT but if a code path reaches this macro it will always quit.
Definition at line 151 of file AssertMacros.h.
#define MCRO_ASSERT_CRASH_COMMON | ( | condition, | |
... ) |
Definition at line 84 of file AssertMacros.h.
#define MCRO_ASSERT_CRASH_METHOD |
Definition at line 57 of file AssertMacros.h.
#define MCRO_ASSERT_QUIT_COMMON | ( | condition, | |
returnOnFailure, | |||
... ) |
Definition at line 90 of file AssertMacros.h.
#define MCRO_ASSERT_SUBMIT_ERROR | ( | condition, | |
severity, | |||
async, | |||
important, | |||
... ) |
Definition at line 49 of file AssertMacros.h.
#define MCRO_CRASH_BODY | ( | condition, | |
... ) |
Definition at line 63 of file AssertMacros.h.
#define MCRO_QUIT_BODY | ( | condition, | |
returnOnFailure, | |||
... ) |
Definition at line 70 of file AssertMacros.h.