diff --git a/pollor.client/src/app/polls/polls.component.ts b/pollor.client/src/app/polls/polls.component.ts index 4da73a9..93d2023 100644 --- a/pollor.client/src/app/polls/polls.component.ts +++ b/pollor.client/src/app/polls/polls.component.ts @@ -30,10 +30,11 @@ export class PollsComponent { this.pollsLoaded = true; }, error: (err) => { - this.pollLoadingMsg = err.status + ' - ' + err.error.message; + const msg = (err.error.message ? err.error.message : err.message); + this.pollLoadingMsg = err.status + ' - ' + msg; this.pollLoadingColor = "red"; console.error(err); - AlertMessage.addErrorAlert(err.error.message); + AlertMessage.addErrorAlert(msg); }, //complete: () => { } }); diff --git a/pollor.client/src/app/user-login/user-login.component.ts b/pollor.client/src/app/user-login/user-login.component.ts index 91928e6..12b3e89 100644 --- a/pollor.client/src/app/user-login/user-login.component.ts +++ b/pollor.client/src/app/user-login/user-login.component.ts @@ -56,9 +56,10 @@ export class UserLoginComponent { AlertMessage.addSuccessAlert("Login is successfull !"); }, error: (err: any) => { - this.loginError = err.error.message; + const msg = (err.error.message ? err.error.message : err.message); + this.loginError = err.status + ' - ' + msg; console.error('Login Error:', err); - AlertMessage.addErrorAlert(err.error.message); + AlertMessage.addErrorAlert(msg); }, }); } @@ -79,9 +80,10 @@ export class UserLoginComponent { this.navigateDashboard(res.user.role); }, error: (err: any) => { - this.loginError = err.error.message; + const msg = (err.error.message ? err.error.message : err.message); + this.loginError = err.status + ' - ' + msg; console.error('Token validation Error:', err); - AlertMessage.addErrorAlert(err.error.message); + AlertMessage.addErrorAlert(msg); }, }); } diff --git a/pollor.client/src/app/user-profile/user-profile.component.ts b/pollor.client/src/app/user-profile/user-profile.component.ts index fb65bc9..6d981bc 100644 --- a/pollor.client/src/app/user-profile/user-profile.component.ts +++ b/pollor.client/src/app/user-profile/user-profile.component.ts @@ -56,9 +56,10 @@ export class UserProfileComponent { this.userLoaded = true; }, error: (err) => { - this.userLoadingMsg = err.status + ' - ' + err.error.message; + const msg = (err.error.message ? err.error.message : err.message); + this.userLoadingMsg = err.status + ' - ' + msg; console.error(err); - AlertMessage.addErrorAlert(err.error.message); + AlertMessage.addErrorAlert(msg); }, //complete: () => { } }); diff --git a/pollor.client/src/app/user-register/user-register.component.ts b/pollor.client/src/app/user-register/user-register.component.ts index b9d830c..c842dfe 100644 --- a/pollor.client/src/app/user-register/user-register.component.ts +++ b/pollor.client/src/app/user-register/user-register.component.ts @@ -65,9 +65,10 @@ export class UserRegisterComponent { AlertMessage.addSuccessAlert("Account registration is successfull !"); }, error: (err: any) => { - this.registerError = err.error.message; + const msg = (err.error.message ? err.error.message : err.message); + this.registerError = err.status + ' - ' + msg; console.error('Login Error:', err); - AlertMessage.addErrorAlert(err.error.message); + AlertMessage.addErrorAlert(msg); }, }); } @@ -88,9 +89,10 @@ export class UserRegisterComponent { this.navigateDashboard(res.user.role); }, error: (err: any) => { - this.registerError = err.error.message; + const msg = (err.error.message ? err.error.message : err.message); + this.registerError = err.status + ' - ' + msg; console.error('Token validation Error:', err); - AlertMessage.addErrorAlert(err.error.message); + AlertMessage.addErrorAlert(msg); }, }); }