Avoid logging errors on Angular 2
What I'm doing is to log in an user, and if the credentials are invalid I throw an exception from the server side. My code is the following:
this.http.post("/login", JSON.stringify(credentials))
.map(result => result.json())
.subscribe(
data =>this.router.navigate(["home"]),
() => this.router.navigate(["login"], {queryParams: {error: true}})
);
In this case I'm authenticating the user if it doesn't throw an error, and change the route when it does. The problem is that even when I catch the error, the chrome console is still showing like it threw an error.
Is there anyway to avoid that? I don't want the user to see that. For me is not an error because I'm doing something with it, and I want to be able to use the message that I get from the server side.
链接地址: http://www.djcxy.com/p/48082.html下一篇: 避免在Angular 2上记录错误