Add more descriptive error message to skill deletion (#31)
Co-authored-by: Phan Huy Tran <p.tran@neusta.de> Reviewed-on: http://git.simonis.lol/angular/ems-frontend/pulls/31 Reviewed-by: Constantin Simonis <constantin@simonis.lol>
This commit is contained in:
parent
d00aec70a0
commit
c06e5a8a2e
@ -9,6 +9,7 @@ import {
|
|||||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||||
import QualificationService from "../../services/qualification.service";
|
import QualificationService from "../../services/qualification.service";
|
||||||
import {MatButton} from "@angular/material/button";
|
import {MatButton} from "@angular/material/button";
|
||||||
|
import {HttpErrorResponse} from "@angular/common/http";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-delete-qualification',
|
selector: 'app-delete-qualification',
|
||||||
@ -36,11 +37,16 @@ export class DeleteComponent {
|
|||||||
next: () => {
|
next: () => {
|
||||||
this.dialogRef.close(true);
|
this.dialogRef.close(true);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error: HttpErrorResponse) => {
|
||||||
console.error('Error deleting qualification:', error);
|
console.error('Error deleting qualification:', error);
|
||||||
|
|
||||||
|
if (error.error.message.includes('SQL')) {
|
||||||
|
// The API message is undescriptive but this is the most common
|
||||||
|
this.apiError = 'This qualification cannot be modified because it is currently assigned to one or more employees';
|
||||||
|
} else {
|
||||||
this.apiError = 'API Error';
|
this.apiError = 'API Error';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user