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