As reported by @Freagarach on #5496, there can be broken behaviour as UnitMotion::PathResult may call RequestLongPath with a garbage path goal when ComputeGoal fails.
This checks the return value everywhere and reacts accordingly in case of failure, to prevent such issues.