Added better error messaging

This commit is contained in:
piratefinn 2017-09-15 17:33:34 +01:00
parent f34c558d41
commit 7f3e9f4fd0
5 changed files with 65 additions and 26 deletions

View file

@ -4,6 +4,7 @@
* Fixed register box view on login page
* Made the form reset properly if adding a new one
* Added better error messages on register and account edit
# v0.0.1

View file

@ -137,7 +137,7 @@
Form validation failed, please ensure the form is filled correctly.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later.
{{registerStatusError}}
</div>
</div>
</div>

View file

@ -16,6 +16,7 @@ export class RegisterComponent {
organisationForm: ValidationManager;
years: Object[];
registerStatus: any;
registerStatusError: string = 'Error received, please try again.';
constructor(
private http: Http,
@ -85,9 +86,18 @@ export class RegisterComponent {
this.router.navigate(['/dashboard']);
},
error => {
console.log( error._body );
console.log('Register Error');
console.log(error);
try {
console.log(error.error);
let jsonError = error.json();
console.log("boop");
this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch(e) {
this.registerStatusError = 'There was a server error, please try again later.';
}
this.registerStatus = "send_failed";
console.log(this.registerStatus)
console.log(this.registerStatus);
}
);
}
@ -125,7 +135,16 @@ export class RegisterComponent {
this.router.navigate(['/dashboard']);
},
error => {
console.log( error._body );
console.log('Register Error');
console.log(error);
try {
console.log(error.error);
let jsonError = error.json();
console.log("boop");
this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch(e) {
this.registerStatusError = 'There was a server error, please try again later.';
}
this.registerStatus = "send_failed";
console.log(this.registerStatus);
}

View file

@ -122,7 +122,7 @@
Form validation failed, please ensure the form is filled correctly.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later.
{{submitStatusError}}
</div>
</div>
</div>
@ -160,7 +160,7 @@
Form validation failed, please ensure the form is filled correctly.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later.
{{submitStatusError}}
</div>
</div>
</div>

View file

@ -14,6 +14,7 @@ export class AccountEditComponent implements OnInit {
accountType: any;
// @ViewChild('fileInput') fileInput;
submitStatus: any;
submitStatusError: string = 'Error received, please try again.';
constructor(
private http: Http,
@ -111,7 +112,16 @@ export class AccountEditComponent implements OnInit {
console.log(this.submitStatus);
},
error => {
console.log( error._body );
console.log('Edit Error');
console.log(error);
try {
console.log(error.error);
let jsonError = error.json();
console.log("boop");
this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch(e) {
this.submitStatusError = 'There was a server error, please try again later.';
}
this.submitStatus = "send_failed";
console.log(this.submitStatus);
}
@ -159,7 +169,16 @@ export class AccountEditComponent implements OnInit {
console.log(this.submitStatus);
},
error => {
console.log( error._body );
console.log('Edit Error');
console.log(error);
try {
console.log(error.error);
let jsonError = error.json();
console.log("boop");
this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch(e) {
this.submitStatusError = 'There was a server error, please try again later.';
}
this.submitStatus = "send_failed";
console.log(this.submitStatus);
}