2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Fixed error initialization syntax

refs https://linear.app/tryghost/issue/CORE-9/remove-eslint-warnings

- Used an incorrect string parameter constructor for ghost errors previously. The errors should be initialized with an object containing a "message" property
This commit is contained in:
Naz 2021-09-22 11:51:37 +02:00
parent 4b70c7e0c0
commit ee43133dd9
2 changed files with 9 additions and 3 deletions

View file

@ -22,7 +22,9 @@ const lastPeriodStart = (startDate, interval) => {
return lastPeriodStartDate.toISO();
}
throw new IncorrectUsageError('Invalid interval specified. Only "month" value is accepted.');
throw new IncorrectUsageError({
message: 'Invalid interval specified. Only "month" value is accepted.'
});
};
module.exports = {

View file

@ -20,7 +20,9 @@ class LimitService {
*/
loadLimits({limits = {}, subscription, helpLink, db, errors}) {
if (!errors) {
throw new IncorrectUsageError(`Config Missing: 'errors' is required.`);
throw new IncorrectUsageError({
message: `Config Missing: 'errors' is required.`
});
}
this.errors = errors;
@ -42,7 +44,9 @@ class LimitService {
this.limits[name] = new MaxLimit({name: name, config: limitConfig, helpLink, db, errors});
} else if (_.has(limitConfig, 'maxPeriodic')) {
if (subscription === undefined) {
throw new errors.IncorrectUsageError({message: 'Attempted to setup a periodic max limit without a subscription'});
throw new errors.IncorrectUsageError({
message: 'Attempted to setup a periodic max limit without a subscription'
});
}
const maxPeriodicLimitConfig = Object.assign({}, limitConfig, subscription);