In the future it would help if you could be more clear with your question. Your question currently was a single screenshot with a title, adding more context really makes it easier for me to understand what problem you have. We have a guide on how to ask great questions if you’re interested.
The mechanism that you’re interested in here might be the try/except
pattern in python. That way you can catch errors and handle them appropriately. There’s a guide on this topic here.