Added an dedicated error in case of a potential CORS issue #39

This commit is contained in:
Nicolas Constant 2019-03-03 18:42:11 -05:00
parent 5a7f6bf87f
commit de42f445b4
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 22 additions and 6 deletions

View File

@ -34,7 +34,13 @@ export class AddNewAccountComponent implements OnInit {
this.redirectToInstanceAuthPage(username, instance, appData); this.redirectToInstanceAuthPage(username, instance, appData);
}) })
.catch((err: HttpErrorResponse) => { .catch((err: HttpErrorResponse) => {
if (err instanceof HttpErrorResponse) {
this.notificationService.notifyHttpError(err); this.notificationService.notifyHttpError(err);
} else if ((<Error>err).message === 'CORS'){
this.notificationService.notify('There is maybe a CORS issue with the server you\'re connecting to. Please check in the console and if so, contact your administrator with those informations.', true);
} else {
this.notificationService.notify('Unkown error', true);
}
}); });
return false; return false;
@ -53,6 +59,13 @@ export class AddNewAccountComponent implements OnInit {
return this.saveNewApp(instance, appData) return this.saveNewApp(instance, appData)
.then(() => { return appData; }); .then(() => { return appData; });
}) })
.catch((err: HttpErrorResponse) => {
if (err.status === 0) {
throw Error('CORS');
} else {
throw err;
}
});
} }
} }

View File

@ -10,6 +10,9 @@
padding: 5px 10px; padding: 5px 10px;
border-radius: 2px; border-radius: 2px;
margin: 0 0 5px 15px; margin: 0 0 5px 15px;
max-width: 305px;
white-space: pre-line;
word-wrap: break-word;
cursor: pointer; cursor: pointer;
&--error{ &--error{

View File

@ -17,7 +17,7 @@ export class NotificationHubComponent implements OnInit {
setTimeout(() => { setTimeout(() => {
this.notifications = this.notifications.filter(x => x.id !== notification.id); this.notifications = this.notifications.filter(x => x.id !== notification.id);
}, 2000); }, 5000);
}); });
//this.autoSubmit(); //this.autoSubmit();