Try/Catch still producing error on page load - Best Practices on loading info

I am learning a lot (thanks to everyone one here for your help!). Today I ran across an issue on a page. As part of the page endpoint, I was running a check against an external API to gather information. I put it in the page endpoint because I use the gathered info in multiple cards further down (that may be in different endpoints). This API check is in a Try/Catch block in case it doesn’t find anything, I don’t want it to error out the page.

Well, today the API was timing out and the page wouldn’t load (returned the time out error to the page load). So, it seems like the try/catch didn’t actually catch the error and move on.

This leads me to a couple of questions. First, am I doing this the best way or are their better ways to catch the info from this API (it is a dynamic page, so it will be unique for each person) and pass that info on to multiple other endpoints? Why didn’t the try/catch move on past the timeout error and keep loading the page?

Thanks for any thoughts on this.

@dkkazak
I remember having this issue in the past so the alternative way i did is by using “-ErrorVariable err”
and then if $err do something.