Check if Texture Exists

Is there a function to check whether a texture or window already exists or whether I need to create one? Furthermore, if I do have an error i MakeTexture is there a way of catching the error before closing the screen?

I keep getting the error that no window or texture exists even though i have a window open and a texture pre-created. This error closes my window.

Error in function DrawTextures: Invalid Window (or Texture) Index provided: It doesn’t correspond to an open window or texture.

My code is

   % Make the image into a texture
        imageTexture1=params.range_ar_trials.texture(params.range_ar_trials.numbers==double(data.trialdata.stim1(trial)))
         imageTexture2=params.range_ar_trials.texture(params.range_ar_trials.numbers==double(data.trialdata.stim2(trial)))

   try 
        Screen('DrawTextures', window,imageTexture1, [], params.left_rect);
        Screen('DrawTextures', window,imageTexture2, [], params.right_rect);
        catch
         left_stimuli=stimuli.image(find(left_stim==stimuli.number));
        right_stimuli=stimuli.image(find(right_stim==stimuli.number));
        
        imag1=stim(left_stimuli).image;
        imag2=stim(right_stimuli).image;
         imageTexture1 = Screen('MakeTexture', window,imag1 );
         imageTexture2 = Screen('MakeTexture', window,imag2 );
        Screen('DrawTextures', window,imageTexture1, [], params.left_rect);
        Screen('DrawTextures', window,imageTexture2, [], params.right_rect);
        end

And in my workspace I have

window: 10
imageTexture1: 37
params.left_rect

ans =

   84.8000
  184.8000
  315.2000
  415.2000

Any help would be greatly appreciated