How to globally handle 500 errors gracefully in Angular

To globally handle 500 errors gracefully in Angular, create a service that looks like this (my code is ES6):

Then in your route config, add this: