title: Angular 4, custom ErrorHandler doesn't recognize custom Error
body: <p>I tried to create a custom global <a href="https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html" rel="noreferrer">ErrorHandler</a> and followed the instruction detailed <a href="https://dpopescu.me/2016/10/21/catching-global-errors-in-angular-2/" rel="noreferrer">here</a></p>
  
  <p><strong>application-error-handler</strong> (just the important parts)</p>
  
  <pre><code>@Injectable()
  export class ApplicationErrorHandler extends ErrorHandler {
  
      constructor(private injector: Injector) {
          super(false);
      }
  
      handleError(error: any): void {
  
          if (error instanceof ApplicationError || error.originalError instanceof ApplicationError) {
              this.addError(error.originalError);
          }
          else {
              super.handleError(error);
          }
      }
  </code></pre>
  
  <p><strong>app-module</strong></p>
  
  <pre><code> providers: [
      {
          provide: ErrorHandler,
          useClass: ApplicationErrorHandler
      }
  ],
  </code></pre>
  
  <p><strong>app.component</strong> (only the important part)</p>
  
  <pre><code>public ngOnInit(): void { 
      const error = new ApplicationError();
      error.message = "fehler";
      throw error;
  } 
  </code></pre>
  
  <p><strong>application-error</strong></p>
  
  <pre><code>export class ApplicationError implements Error {
      name: string;
      message: string;
      httpStatus?: number = 404;
      applicationStatus?: number;
      errorMessageTranslationkey: string;
      handled: boolean = false;
  }
  </code></pre>
  
  <p>in my app.component I throw an ApplicationError (in ngOnInit), my ErrorHandler gets called successfully.
  But my error in <code>handleError</code> is always of type <code>Error</code> and <code>error.originalError</code> is always <code>undefined</code> no matter if I throw my custom error and there the <code>if</code> will never resolve to true.</p>
  
  <p>I have no idea why and how this happens.
  What I see is that the error gets, so I assume, wrapped because when I debug I see <code>error: Error: [object: Object] at viewWrappedDebugError (vendor.bundle.js)</code></p>
  
  <p>Any idea what might cause this issue and how I can resolve it?</p>
  
  <p><strong>EDIT</strong>
  As suspected it has something to do with Debugmode. As soon as I enable prodmode with <code>enableProdMode();</code> it works as expected.</p>
  
  <p>Still this doesn't really answer my question yet.</p>
  
  <p><strong>How can I handle my custom error in angular's debug mode?</strong></p>