Angular 9: instance of error not working with custom error handler

I am trying to implement custom error handling using the ErrorHandler class in angular

My Globalerror service looks like this

export class CustomErrors extends Error {
  button?: any;
  errObject: any;
  constructor() {
    Object.setPrototypeOf(this, CustomErrors.prototype);
export class GlobalErrorHandler implements ErrorHandler {
  // constructor(private injector: Injector) {}
  constructor() {}

  handleError(error: any) {
    console.log('custom error', error instanceof CustomErrors);


In the component, I’m testing

ngOnInit() {
    try {
        throw new Error('error on do the thing');
    catch (err) {
        const errs = new CustomErrors();
         //console.log('in service', errs instanceof CustomErrors);
          errs.button = 'Back to the start';
          throw err;

but the console message in the handlerror function console.log('custom error', error instanceof CustomErrors); always throws false

I am not sure why it’s not getting true

153 thoughts on “Angular 9: instance of error not working with custom error handler”

  1. Pingback: viagra prices
  2. Pingback: sildenafil coupon
  3. Pingback: sildenafil 20mg
  4. Pingback: how to buy cialis
  5. Pingback: order cialis
  6. Pingback: viagra sample
  7. Pingback: cialis 10
  8. Pingback: lovegra
  9. Pingback: buy cialis viagra
  10. Pingback: cialis medication
  11. Pingback: cialis generique
  12. Pingback: sildenafil india
  13. Pingback: sildenafil generic
  14. Pingback: hims viagra
  15. Pingback: price for viagra
  16. Pingback: womens viagra
  17. Pingback: viagra cock
  18. Pingback: walgreens viagra
  19. Pingback: sildenafil citrate
  20. Pingback: lady viagra
  21. Pingback: viagra substitute
  22. Pingback: female viagra
  23. Pingback: teva sildenafil
  24. Pingback: viagra vs cialis

Leave a Comment