By default, Angular comes with its own ErrorHandler. This error handler captures all errors inside our angular app and prevents the app from crashing.
If you want to implement your own error handling logic, this would be a good place to start. Therefore we have to create a new class that inherits from ErrorHandler:
Inside this ErrorHandler we use our own ErrorService:
This ErrorService exposes an observable that can be used to subscribe to errors in different places.
The ErrorHandler is registered inside our AppModule: