Skip to main content

Posts

Showing posts with the label Angular 5 ErrorHandler

How to catch and log specific Angular errors in your app?

How to catch and log specific Angular errors in your app? The default implementation of ErrorHandler log error messages, status, and stack to the console.  To intercept error handling, we write a custom exception handler that replaces this default as appropriate for your app. import { Injectable , ErrorHandler } from '@angular/core' ; import { ErrorLoggService } from './error-logg.service' ; // Global error handler for logging errors @ Injectable () export class GlobalErrorHandler extends ErrorHandler {     constructor ( private errorLogService : ErrorLoggService ) {        //Angular provides a hook for centralized exception handling.        //constructor ErrorHandler(): ErrorHandler         super ();     }     handleError ( error ) : void {         this . errorLo...

Angular 5 ErrorHandler - Custom and Global Error Handling

How to catch and log specific Angular errors in your app? The default implementation of ErrorHandler log error messages, status, and stack to the console. To intercept error handling, we write a custom exception handler that replaces this default as appropriate for your app. import { Injectable , ErrorHandler } from '@angular/core' ; import { ErrorLoggService } from './error-logg.service' ; // Global error handler for logging errors @ Injectable () export class GlobalErrorHandler extends ErrorHandler {     constructor ( private errorLogService : ErrorLoggService ) {        //Angular provides a hook for centralized exception handling.        //constructor ErrorHandler(): ErrorHandler         super ();     }     handleError ( error ) : void {         this . errorLogService...