Generating a number until a condition is met

Hello, so i am generating a random angle at which i want to instantiate an object, and I want to exclude a certain range of degrees. The code looks like this:

void Spawn()
    {
        angle = Random.Range(0f, 360f) * Mathf.Deg2Rad;
        
      if(angle < maxAngle && angle > minAngle)
        {
            //Instantiate
        }

How can I make it reroll the angle if the condition in if statement is not met and then check again?

You could just call the function again like this:

 void Spawn()
     {
         angle = Random.Range(0f, 360f) * Mathf.Deg2Rad;
         
       if(angle < maxAngle && angle > minAngle)
         {
             //Instantiate
         } 
         else
         {
             Spawn()
         }

Just Put the Whole thing into an Update function

void update()
{
    If(!Condition_met)
    {
         angle = Random.Range(0f, 360f) * Mathf.Deg2Rad;
          
        if(angle < maxAngle && angle > minAngle)
          {
              //Instantiate
             Condition_met=true;
          } 
    }
}