Lecture 166 - !ensure spitting out huge errors (v 4.14)

Hey, so I started using !ensure to check for null pointers and such, and found that instead of a few lines of code that are yellow like Ben’s that I instead get about 30 lines of red code all beginning with LogOutputDevice:Error, a few of which do specify where the problem stems from but most of which are referencing various .dll files.

I was wondering if this is a sign my code isn’t right, if this is something new to 4.13/4.14, or if may have to do with some kind of settings I need to adjust. To be clear, it starts up fine, runs fine, and takes about as long to check the code as Ben’s does, it just gives me much longer messages than I would have thought it would.

I get this as well, I assume there must be a way to turn this behaviour off, but I couldn’t find it. Anyone?

Mind sharing your project and/or screenshots as to what you’re referring to?


This is a single ensure fail. Not only does it fill the entire screen, but the red on grey ia very hard to read.

I got that in someone else’s repo too. Couldn’t track what caused it then again I didn’t spend too long on trying to figure it out as that wasn’t the problem I was originallly trying to solve. Will look further into it though.

It only seems to appear once when pressing Play initially after the editor has loaded and after a few minutes has passed after the last play session.

I thought I might have seen a WarningsAsErrors flag go by somewhere in the Log.

Seems to happen with Ben’s as well. I got rid of the ensure in the SetPawn() method so it looks like this

void ATankAIController::SetPawn(APawn* InPawn)
{
	Super::SetPawn(InPawn);
	if (InPawn)
	{
		auto PossessedTank = Cast<ATank>(InPawn);
		// Subscribe our local method to the tank's death event
		if (PossessedTank)
			PossessedTank->OnDeath.AddUniqueDynamic(this, &ATankAIController::OnPossedTankDeath);
	}
}

And it seems to work better.

I have spent some time scratching my head over this response and I fail to see why it is relevant. What is this code you show? I am completely lost here.

I changed

void ATankAIController::SetPawn(APawn* InPawn)
{
	Super::SetPawn(InPawn);
	if (InPawn)
	{
		auto PossessedTank = Cast<ATank>(InPawn);
		// Subscribe our local method to the tank's death event
		if (!ensure(PossessedTank)) { return; }
		PossessedTank->OnDeath.AddUniqueDynamic(this, &ATankAIController::OnPossedTankDeath);
	}
}

to the code above.

And where does this code come from, and what does it have to do with the problem?

Oh yours is from the TankPlayerController. Though I’m not entirely sure why but an ensure statement that was written fails when you press play and I assume is attempted again seeing how the functionality of the code still works?

What is the ensure statement that’s failing for you? It says in TankPlayerController line 35.

It happens with EVERY failed ensure.

Well that’s the point of the ensure

Privacy & Terms