From c06e5a8a2e62068f369d56d38f99ffad26d8b0cf Mon Sep 17 00:00:00 2001 From: Huy Date: Wed, 15 Jan 2025 07:44:23 +0000 Subject: [PATCH] Add more descriptive error message to skill deletion (#31) Co-authored-by: Phan Huy Tran Reviewed-on: http://git.simonis.lol/angular/ems-frontend/pulls/31 Reviewed-by: Constantin Simonis --- src/app/qualification/delete/delete.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/qualification/delete/delete.component.ts b/src/app/qualification/delete/delete.component.ts index e77996b..0d849d0 100644 --- a/src/app/qualification/delete/delete.component.ts +++ b/src/app/qualification/delete/delete.component.ts @@ -9,6 +9,7 @@ import { import {FormsModule, ReactiveFormsModule} from "@angular/forms"; import QualificationService from "../../services/qualification.service"; import {MatButton} from "@angular/material/button"; +import {HttpErrorResponse} from "@angular/common/http"; @Component({ selector: 'app-delete-qualification', @@ -36,10 +37,15 @@ export class DeleteComponent { next: () => { this.dialogRef.close(true); }, - error: (error) => { + error: (error: HttpErrorResponse) => { console.error('Error deleting qualification:', error); - this.apiError = 'API 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'; + } } }); }