Added better error messaging
This commit is contained in:
parent
f34c558d41
commit
7f3e9f4fd0
5 changed files with 65 additions and 26 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
* Fixed register box view on login page
|
* Fixed register box view on login page
|
||||||
* Made the form reset properly if adding a new one
|
* Made the form reset properly if adding a new one
|
||||||
|
* Added better error messages on register and account edit
|
||||||
|
|
||||||
# v0.0.1
|
# v0.0.1
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
Form validation failed, please ensure the form is filled correctly.
|
Form validation failed, please ensure the form is filled correctly.
|
||||||
</div>
|
</div>
|
||||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||||
Failed to send to server, please try again later.
|
{{registerStatusError}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,6 +16,7 @@ export class RegisterComponent {
|
||||||
organisationForm: ValidationManager;
|
organisationForm: ValidationManager;
|
||||||
years: Object[];
|
years: Object[];
|
||||||
registerStatus: any;
|
registerStatus: any;
|
||||||
|
registerStatusError: string = 'Error received, please try again.';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: Http,
|
private http: Http,
|
||||||
|
@ -85,9 +86,18 @@ export class RegisterComponent {
|
||||||
this.router.navigate(['/dashboard']);
|
this.router.navigate(['/dashboard']);
|
||||||
},
|
},
|
||||||
error => {
|
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";
|
this.registerStatus = "send_failed";
|
||||||
console.log(this.registerStatus)
|
console.log(this.registerStatus);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +135,16 @@ export class RegisterComponent {
|
||||||
this.router.navigate(['/dashboard']);
|
this.router.navigate(['/dashboard']);
|
||||||
},
|
},
|
||||||
error => {
|
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";
|
this.registerStatus = "send_failed";
|
||||||
console.log(this.registerStatus);
|
console.log(this.registerStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
Form validation failed, please ensure the form is filled correctly.
|
Form validation failed, please ensure the form is filled correctly.
|
||||||
</div>
|
</div>
|
||||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||||
Failed to send to server, please try again later.
|
{{submitStatusError}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -160,7 +160,7 @@
|
||||||
Form validation failed, please ensure the form is filled correctly.
|
Form validation failed, please ensure the form is filled correctly.
|
||||||
</div>
|
</div>
|
||||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||||
Failed to send to server, please try again later.
|
{{submitStatusError}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,6 +14,7 @@ export class AccountEditComponent implements OnInit {
|
||||||
accountType: any;
|
accountType: any;
|
||||||
// @ViewChild('fileInput') fileInput;
|
// @ViewChild('fileInput') fileInput;
|
||||||
submitStatus: any;
|
submitStatus: any;
|
||||||
|
submitStatusError: string = 'Error received, please try again.';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: Http,
|
private http: Http,
|
||||||
|
@ -111,7 +112,16 @@ export class AccountEditComponent implements OnInit {
|
||||||
console.log(this.submitStatus);
|
console.log(this.submitStatus);
|
||||||
},
|
},
|
||||||
error => {
|
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";
|
this.submitStatus = "send_failed";
|
||||||
console.log(this.submitStatus);
|
console.log(this.submitStatus);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +169,16 @@ export class AccountEditComponent implements OnInit {
|
||||||
console.log(this.submitStatus);
|
console.log(this.submitStatus);
|
||||||
},
|
},
|
||||||
error => {
|
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";
|
this.submitStatus = "send_failed";
|
||||||
console.log(this.submitStatus);
|
console.log(this.submitStatus);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue