GameObject return if, else

I am having difficulties creating a GameObject class, basically what I want is for unity to stop throwing errors when the powerUpPrefabs array is empty and ideally print out a debug.log saying that the array is empty.

    private GameObject RandomPowerUp()
    {
        if (powerUpPrefabs.Length != 0)
        {
            return powerUpPrefabs[Random.Range(0, powerUpPrefabs.Length)];
        }
        else
        {
            //what do I type here so it doesn't throw an error?
        }
    }

What I am struggling with is figuring out what to type in the else statement, because it requires a GameObject to be return which neither the debug.log nor null is.

It depends on your code I would think NULL just check for that before you go instantiating something… or check that you have something in this array before calling this function and you could use if(powerUpPrefabs.Length > 1){//code}else return powerUpPrefabs[0];

this should be a bit easier to read

public GameObject SpawnRandomPowerUp()
{
    if (powerUp != Random.Range(1, powerUpChance))
    {
        return null;
    }

    GameObject powerUpOObject = RandomPowerUp();

    if (powerUpOObject == null)
    {
        return null;
    }

    return Instantiate(RandomPowerUp(), transform.position, transform.rotation);
}

private GameObject RandomPowerUp()
{
    if (powerUpPrefabs.Length == 0)
    {
        return null;
    }

    return powerUpPrefabs[Random.Range(0, powerUpPrefabs.Length)];
}

I figured out the message @xxmariofer were trying to convey and added this snippet of code where the main function is called:

        {
            DestroyBlock();
            if (thePowerUp.powerUpPrefabs.Length != 0)
            {
                thePowerUp.SpawnRandomPowerUp().transform.position = this.transform.position; 
            }
            else
            {
                Debug.Log("No PowerUps loaded");
            }
        }

This also requires a lot less nulls in the PowerUp function, so now the code looks cleaner:

public class PowerUpSpawn : MonoBehaviour
{
    int powerUp = 1;
    [SerializeField] int powerUpChance;
    public GameObject[] powerUpPrefabs;

    public GameObject SpawnRandomPowerUp()
    {
        if (powerUp == Random.Range(1, powerUpChance)) 
        {
            return Instantiate(RandomPowerUp(), transform.position, transform.rotation);
        }
        else
        {
            return null;
        }
    }

    private GameObject RandomPowerUp()
    {
        return powerUpPrefabs[Random.Range(0, powerUpPrefabs.Length)];
    }
}