So I want to handle a scenario where my Angular app failed to load or crashed due to an error and in those cases like a 'noscript tag' I want to display something helpful.
The primary reason for this is I noticed some of my angular modules may get blocked by an AdBlocker so the js file that instantiates that module does not get loaded and the App gives a 'nomodule error'.
Are there any best practices or ways to handle such situations so I could at least display a message telling my users a meaningful message?
As right now when this happens I just get a blank white page... not good.
So after trying several things, I found this as a way to handle such errors that involve angular failing to initialise:
// init the app manually and catch any errors
try {
angular.bootstrap(document, [myApp]);
} catch(e) {
window.location.href = '/app-load-error'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With