How to Exit a Game after Function returning NullPtr

Hi,

in C I would handle a nullptr problem like that:

if( (myPtr = myFunction()) == NULL)
{
    printf("Error@myFunction: myPtr is NULL")
    exit(1);
}

My Question:

How would I accomplish something like this in Unreal?

Because all examples I found always show something like this:

if( (myPtr = myFunction()) != NULL)
{
    // something with myPtr-> ... 
}

I dont understand how this solves the problem when there is code all around which uses myPtr.
Then you always have to check this with an expensive if-branch.

No doubt, the C++ equivalent of

image

( whatever that is ).

There’s a UE macro you can call from c++ called “check” which throws an exception so if you’re in debug mode it takes you to that line of code:

check(GetCachedMeshDescription() == nullptr);

1 Like