angular: Custom Exception Handler

Hi all!

I’ve been trying to implement my own ExceptionHandler and followed the docs: https://angular.io/docs/ts/latest/api/core/ExceptionHandler-class.html

However, I am using ES6, so I can’t implement interfaces. I couldn’t get the call method trigger 😕

Also, the docs say “export class” but use it as an interface (“implements ExceptionHandler”), is this correct?

This is my ExceptionHandler:

import { ExceptionHandler } from 'angular2/core';

export class WtExceptionHandler extends ExceptionHandler {
  call(error, stackTrace = null, reason = null) {
    console.log("hello");
  }
}

But my transpiled code shows ‘call’ method as:

call(error) { ... } // And stackTrace and reason comes from arguments. Could this be the issue?

Best regards, tbragaf

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 33 (5 by maintainers)

Most upvoted comments

does anyone have a way to do this on RC6+ ? the ExceptionHandler is nolonger public

@liquidboy import { ErrorHandler } from "@anguar/core" instead

@ndamnjanovic I don’t know how that works on typescript, since I don’t use it. But the construtor needs an Logger, which is not passed as a dependency for the DI to instanciate, but rather instanciated manually. I know it seems unusual, but copy the logger from the source code, and call it inside your super call.