How do I stop unnecessary nullreferencexceptions from printing?

I have a script for my zombie enemies that detects which body parts have been destroyed, produces an instantiate of that body part, and keeps from checking again. It was tedious to set up and calls each part by name but it works smoothly and without any lag or real problems and successfully changes the animation states to crawling, falling, etc. The issue becomes that the spawn points for these parts have to move with the bones so they are inside of them, and when the part is destroyed so is the spawn, which is good. However if say you blast off the right hand, and the hand shoots out, and then later blast off the right elbow or whatever bone part is next up the line since the spawn or connected bones for that arm is no longer there it throws a nullreferenceexception. I want that to be a null reference, and I’m glad it comes back as such or the code wouldn’t work but I don’t need to see it in my debug everytime. I’ve tried using else null; commands and cant seem to figure out how to get the darn thing to stop stating the obvious, which is if you dont have a right elbow then of course you wont have a right hand either so on and so forth. I suppose its not a problem with functionality it just creates a messy debug log.

This is an example of the full to partial right arm detection and body part creation portion of the AI script, others run to check if there is still hands/elbows to determine which model to instantiate. Is there something obviously wrong in how I’ve arranged it? I’ve only been using unity for a couple weeks so a lot of it is new to me and I’m sure its glaring me in the face.

if(rarm)
	{
	var rarmcheck = transform.Find("Armature/Root/Bone_001/MidSpine/Bone_003/Bone_003_R/RightElbow");
	if(!rarmcheck)
	{
		rarm = false;

				if(!rarm && !rhand && !relb)
			  {
				var ras = Instantiate(ram,transform.Find("Armature/Root/Bone_001/MidSpine/Bone_003/Bone_003_R/raspawn").transform.position, Quaternion.identity);
				ras.transform.Rotate(20, 10, 10);
				ras.rigidbody.velocity = ras.transform.down * 2; 	
			  //only bicep
			  }

				if(!rarm && !rhand && relb ) 
			  {
			  	var raes = Instantiate(raem,transform.Find("Armature/Root/Bone_001/MidSpine/Bone_003/Bone_003_R/raspawn").transform.position, Quaternion.identity);
				raes.transform.Rotate(20, 10, 10);
				raes.rigidbody.velocity = raes.transform.down * 2; 	
			  //bicep elbow and hand
			  }

			  	if(!rarm && rhand && relb) 
			  {
			  	var raehs = Instantiate(raehm,transform.Find("Armature/Root/Bone_001/MidSpine/Bone_003/Bone_003_R/raspawn").transform.position, Quaternion.identity);
				raehs.transform.Rotate(20, 10, 10);
				raehs.rigidbody.velocity = raehs.transform.down * 2; 	
			  //whole arm
			  }

	}

Any help or suggestions would be much appreciated, and if it really is a non issue then that would be great to hear as well since it seems as such.

Check if objects exists before you use them.

if('object causing null reference')
    'object causing null reference'.Use();

I figured it out! Its a combination of trying to check from grandchild to child, not having elseifs inside the main bodycheck groupings, and that when it does the individual checks for the hand etc, it should also check if there is an arm and an elbow, other wise its redundant and will come back null but only once because the other checks are working and it will still work because the spawns are destroyed anyway. Larm, or rarm, or lleg or rleg checks are always going to be fine because they are holding the other parts so the individual checks were really just running redundantly. Testing has shown this is the reason so thank you everyone for your help you’ve made this a lot easier.

Second result from googling “javascript ignore nullreferenceexception”:
Tell JavaScript To Ignore NullReferenceException?

As noted in some of the comments of that question, ignoring the exception isn’t the best practice out there. Even if you have to rebuild parts, it would be safer and build better habits if you found the specific cause.