0
認証でエラーをトラップするにはどうすればよいですか?私は悪い認証のために優雅な失敗をしたいときにコンソールで厄介なエラーを取得します。エラーのための私の警告は表示されません。認証でエラーをトラップする方法はありますか?
constructor(public af: AngularFire){
this.af.auth.subscribe(user => {
console.log('---->', user)
if (user) {
this.user = user.auth.providerData[0];
if (user.auth.emailVerified==false){
user.auth.sendEmailVerification().then(function() {
alert('Email Verification Sent!');
});
} else {
this.router.navigate(['/dashboard']);
}
},error => { alert('dude whats up with this?')
});
}
onSubmit(){
console.log(this.email,this.password)
this.af.auth.login({
email: this.email,
password: this.password,
},
{
provider: AuthProviders.Password,
method: AuthMethods.Password,
})
}
XCEPTION: Uncaught (in promise): Error: The email address is badly formatted.ErrorHandler.handleError @ error_handler.js:45next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:207Zone.runGuarded @ zone.js:113_loop_1 @ zone.js:379drainMicroTaskQueue @ zone.js:386ZoneTask.invoke @ zone.js:308
error_handler.js:50 ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:50next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:207Zone.runGuarded @ zone.js:113_loop_1 @ zone.js:379drainMicroTaskQueue @ zone.js:386ZoneTask.invoke @ zone.js:308
error_handler.js:51 Error: Uncaught (in promise): Error: The email address is badly formatted.
at resolvePromise (zone.js:429)
at resolvePromise (zone.js:414)
at zone.js:462
at ZoneDelegate.invokeTask (zone.js:236)
at Object.onInvokeTask (ng_zone_impl.js:34)
at ZoneDelegate.invokeTask (zone.js:235)
at Zone.runTask (zone.js:136)
at drainMicroTaskQueue (zone.js:368)
at HTMLFormElement.ZoneTask.invoke (zone.js:308)ErrorHandler.handleError @ error_handler.js:51next @ application_ref.js:273schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:120onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:207Zone.runGuarded @ zone.js:113_loop_1 @ zone.js:379drainMicroTaskQueue @ zone.js:386ZoneTask.invoke @ zone.js:308
zone.js:355 Unhandled Promise rejection: The email address is badly formatted. ; Zone: angular ; Task: Promise.then ; Value: R {code: "auth/invalid-email", message: "The email address is badly formatted."} undefinedconsoleError @ zone.js:355_loop_1 @ zone.js:382drainMicroTaskQueue @ zone.js:386ZoneTask.invoke @ zone.js:308
zone.js:357 Error: Uncaught (in promise): Error: The email address is badly formatted.(…)