Creating a Global Error Handler
Learn how to create a global error handler for handling server and client-side errors.
We'll cover the following
The Angular framework provides the ErrorHandler
class for handling errors globally in an Angular application. The default implementation of the ErrorHandler
class prints error messages in the browser console window. To create a custom error handler for our application, we need to sub-class the ErrorHandler
class and provide our tailored implementation for error logging:
Create a file named
app-error-handler.ts
in thesrc\app
folder of an Angular application.Add the following
import
statements:
Get hands-on with 1200+ tech skills courses.