Improved error messages for Offers API

no-issue
This commit is contained in:
Fabien O'Carroll 2021-10-22 16:48:52 +02:00
parent af1a019f0e
commit 668a9d47ba
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
const {GhostError} = require('@tryghost/errors');
const {ValidationError} = require('@tryghost/errors');
class InvalidPropError extends GhostError {
class InvalidPropError extends ValidationError {
/** @param {any} options */
constructor(options) {
super({

View File

@ -192,7 +192,7 @@ class Offer {
}
if (!await uniqueChecker.isUniqueCode(code)) {
throw new errors.InvalidOfferCode({
message: 'Offer `code` must be unique.'
message: `Offer 'code' must be unique. Please change and try again.`
});
}
this.changed.code = this.props.code;
@ -210,7 +210,7 @@ class Offer {
}
if (!await uniqueChecker.isUniqueName(name)) {
throw new errors.InvalidOfferName({
message: 'Offer `name` must be unique.'
message: `Offer 'name' must be unique. Please change and try again.`
});
}
this.props.name = name;
@ -288,7 +288,7 @@ class Offer {
if (isNew) {
if (!await uniqueChecker.isUniqueName(name)) {
throw new errors.InvalidOfferName({
message: 'Offer `name` must be unique.'
message: `Offer 'name' must be unique. Please change and try again.`
});
}
}
@ -296,7 +296,7 @@ class Offer {
if (isNew) {
if (!await uniqueChecker.isUniqueCode(code)) {
throw new errors.InvalidOfferCode({
message: 'Offer `code` must be unique.'
message: `Offer 'code' must be unique. Please change and try again.`
});
}
}