Angular 5 Custom 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.errorLogService.logError(error);
    }
}

For more detail kindly refer the link.... 
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

How to catch and log specific Angular errors in your app? How to catch and log specific Angular errors in your app? Reviewed by Anil Singh on 12:16 AM Rating: (5)
www.code-sample.com/. Powered by Blogger.
^