From d206d7a77ca9ba38ef53ab2db8f98deff3fd81b9 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Mon, 13 Jan 2025 10:37:53 +0100 Subject: [PATCH] enhance: provide more details to command delete error --- src/command/settings/award/awardCommandHandler.ts | 5 ++++- .../settings/calendarType/calendarTypeCommandHandler.ts | 5 ++++- .../communicationType/communicationTypeCommandHandler.ts | 7 ++++++- .../executivePosition/executivePositionCommandHandler.ts | 7 ++++++- .../membershipStatus/membershipStatusCommandHandler.ts | 7 ++++++- .../settings/qualification/qualificationCommandHandler.ts | 5 ++++- .../settings/queryStore/queryStoreCommandHandler.ts | 5 ++++- src/command/settings/template/templateCommandHandler.ts | 5 ++++- 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/command/settings/award/awardCommandHandler.ts b/src/command/settings/award/awardCommandHandler.ts index af0000f..2a525a9 100644 --- a/src/command/settings/award/awardCommandHandler.ts +++ b/src/command/settings/award/awardCommandHandler.ts @@ -60,7 +60,10 @@ export default abstract class AwardCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting award", err); + throw new InternalException( + `Failed deleting award ${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/calendarType/calendarTypeCommandHandler.ts b/src/command/settings/calendarType/calendarTypeCommandHandler.ts index bc20d6a..702728d 100644 --- a/src/command/settings/calendarType/calendarTypeCommandHandler.ts +++ b/src/command/settings/calendarType/calendarTypeCommandHandler.ts @@ -66,7 +66,10 @@ export default abstract class CalendarTypeCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting calendarType", err); + throw new InternalException( + `Failed deleting calendarType${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/communicationType/communicationTypeCommandHandler.ts b/src/command/settings/communicationType/communicationTypeCommandHandler.ts index 04c7f10..df11e20 100644 --- a/src/command/settings/communicationType/communicationTypeCommandHandler.ts +++ b/src/command/settings/communicationType/communicationTypeCommandHandler.ts @@ -66,7 +66,12 @@ export default abstract class CommunicationTypeCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting communicationType", err); + throw new InternalException( + `Failed deleting communicationType${ + err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : "" + }`, + err + ); }); } } diff --git a/src/command/settings/executivePosition/executivePositionCommandHandler.ts b/src/command/settings/executivePosition/executivePositionCommandHandler.ts index d1be38d..14a31a5 100644 --- a/src/command/settings/executivePosition/executivePositionCommandHandler.ts +++ b/src/command/settings/executivePosition/executivePositionCommandHandler.ts @@ -64,7 +64,12 @@ export default abstract class ExecutivePositionCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting executivePosition", err); + throw new InternalException( + `Failed deleting executivePosition${ + err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : "" + }`, + err + ); }); } } diff --git a/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts b/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts index bc9f30f..7e5e953 100644 --- a/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts +++ b/src/command/settings/membershipStatus/membershipStatusCommandHandler.ts @@ -64,7 +64,12 @@ export default abstract class MembershipStatusCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting membershipStatus", err); + throw new InternalException( + `Failed deleting membershipStatus${ + err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : "" + }`, + err + ); }); } } diff --git a/src/command/settings/qualification/qualificationCommandHandler.ts b/src/command/settings/qualification/qualificationCommandHandler.ts index 0abd401..b0b9f22 100644 --- a/src/command/settings/qualification/qualificationCommandHandler.ts +++ b/src/command/settings/qualification/qualificationCommandHandler.ts @@ -66,7 +66,10 @@ export default abstract class QualificationCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting qualification", err); + throw new InternalException( + `Failed deleting qualification${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/queryStore/queryStoreCommandHandler.ts b/src/command/settings/queryStore/queryStoreCommandHandler.ts index 3776b5e..e8c6917 100644 --- a/src/command/settings/queryStore/queryStoreCommandHandler.ts +++ b/src/command/settings/queryStore/queryStoreCommandHandler.ts @@ -63,7 +63,10 @@ export default abstract class QueryStoreCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting queryStore", err); + throw new InternalException( + `Failed deleting queryStore${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } } diff --git a/src/command/settings/template/templateCommandHandler.ts b/src/command/settings/template/templateCommandHandler.ts index 54ea6f7..6a88353 100644 --- a/src/command/settings/template/templateCommandHandler.ts +++ b/src/command/settings/template/templateCommandHandler.ts @@ -64,7 +64,10 @@ export default abstract class TemplateCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting template", err); + throw new InternalException( + `Failed deleting template${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`, + err + ); }); } }