Catching "Your app is having trouble loading the ..." warning in Python

Is there any way to catch “Your app is having trouble loading the …” warning in Python? I would like to handle it instead of showing a message like the following one.

The message seems to be generated in Typescript.