estus estus - 2 months ago 23
Javascript Question

Notify on Angular 2 app initialization error

An uncaught exception (injector or just random error) in any component during bootstrap may lead to bootstrap failure.

Due to browser incompatibility the app may not start bootstrap process at all.

I'm looking for a way to notify a user (with alert, modal, etc) on critical error that happened during Angular 2 app initialization, so a user could be sure that the app not just loads forever but failed for some reason.

What's the good recipe to handle this case in Angular 2?


PlatformRef.bootstrapModule return's a promise where we can .catch the error, while bootstrap(initializing) the app.

    .catch(er‌​r => console.error(err));

There was a bug, which was just resolved(changelog). Thanks to @estus, for pointing it out.