IFrames generally cannot interact with the page into which they are embedded, and it is all at the browser, so there's simply no way to make a try-except
structure. The only approach I can think of is to verify the validity of the URL via httpClient
before you ever allow it to be used in an IFrame.