fix: add userFriendlyMessage to handleDuplicateKeyError (#13513)

/closes #13512
This commit is contained in:
neo773
2025-07-31 12:32:08 +05:30
committed by GitHub
parent 689a346c2e
commit 66c484fe11
@@ -33,7 +33,9 @@ export const handleDuplicateKeyError = (
});
if (!isDefined(affectedColumns)) {
throw new UserInputError(`A duplicate entry was detected`);
throw new UserInputError(`A duplicate entry was detected`, {
userFriendlyMessage: `This record already exists. Please check your data and try again.`,
});
}
const columnNames = affectedColumns.join(', ');
@@ -41,11 +43,17 @@ export const handleDuplicateKeyError = (
if (affectedColumns?.length === 1) {
throw new UserInputError(
`Duplicate ${columnNames}. Please set a unique one.`,
{
userFriendlyMessage: `This ${columnNames.toLowerCase()} is already taken. Please choose a different value.`,
},
);
}
throw new UserInputError(
`A duplicate entry was detected. The combination of ${columnNames} must be unique.`,
{
userFriendlyMessage: `This combination of ${columnNames.toLowerCase()} already exists. Please use different values.`,
},
);
}
};