angular: enableProdMode, If have any exception, the application will crash (don't re-display data when go to another router)

Hi all, I use angular 2.1.2 and I need to customize ErrorHandler.

“AppModule.ts”:

@Injectable()
class MyErrorHandler implements ErrorHandler {
    handleError(error) {
        console.error("EXCEPTION:", error.message);
        console.error("EXCEPTION:", error.stack);

        setTimeout(() => {
            location.href = "#/error";
            return Observable.of([]);
        });
    }
}

or

@Injectable()
export class MyErrorHandler {
    private appRef;

    constructor(private injector:Injector) {
        setTimeout(() => this.appRef = injector.get(ApplicationRef));
    }

    handleError(exception) {
        this.appRef.tick();
        console.error('EXCEPTION:', exception);
    }
}

When I go to /about page and an error occurs. My app will redirect to /error page. Then I go to /home or another page. The data of this page don’t show on template, just show template without any data. How can I resolve it?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

Hello, we reviewed this issue and determined that it doesn’t fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular.

If you are wondering why we don’t resolve support issues via the issue tracker, please check out this explanation.