You can probably do something like this;
<script>
let checkForCurrentErrors = setInterval(() => {
if(__currentPerchanceErrorCount > 0) {
clearInterval(checkForCurrentErrors)
errorPage.style.display = 'block';
}
}, 10)
</script>
<div id="errorPage" style="position: absolute; z-index: 999; display: none; width: 100dvw; height: 100dvh; background: blue;">
Testing Error Page <br>
Please Reload the Page
</div>
It is an interval that checks if there was a perchance error happened. You could also probably have a timeout in which if the page doesn't load for more than 30 seconds, then it would show the error page.
However, these solutions only happen when the page has already been working, meaning, if they just opened up the page, it would still take the Perchance server to send the data first before it loads (where the loading issues might happen), in which case, it needs a server-side code to fire to report that the generator isn't loading.
Depending on the error you want to handle, there might be solutions that we can code and not need the server to provide it for us.