The commands try/catch are used for executing statements and catch errors messages not warning messages.
Since getting a warining can still allow you to run the model, you have to catch the specific warning message and include a 'break' in your for-loop.
A way to catch the warning message is by looking at the following variable when running a model:
For example, when a model has a unconnected outport, the value of this variable is
Then, your code will include something like:
Hope it helps!