diff --git a/ghost/limit-service/lib/date-utils.js b/ghost/limit-service/lib/date-utils.js index 7e1943137b..bae0847ffc 100644 --- a/ghost/limit-service/lib/date-utils.js +++ b/ghost/limit-service/lib/date-utils.js @@ -1,4 +1,5 @@ const {DateTime} = require('luxon'); +const {IncorrectUsageError} = require('@tryghost/errors'); const SUPPORTED_INTERVALS = ['month']; /** @@ -21,7 +22,7 @@ const lastPeriodStart = (startDate, interval) => { return lastPeriodStartDate.toISO(); } - throw new Error('Invalid interval specified. Only "month" value is accepted.'); + throw new IncorrectUsageError('Invalid interval specified. Only "month" value is accepted.'); }; module.exports = { diff --git a/ghost/limit-service/lib/limit-service.js b/ghost/limit-service/lib/limit-service.js index c0e8ed1030..3df5357af0 100644 --- a/ghost/limit-service/lib/limit-service.js +++ b/ghost/limit-service/lib/limit-service.js @@ -1,5 +1,6 @@ const {MaxLimit, MaxPeriodicLimit, FlagLimit, AllowlistLimit} = require('./limit'); const config = require('./config'); +const {IncorrectUsageError} = require('@tryghost/errors'); const _ = require('lodash'); class LimitService { @@ -19,7 +20,7 @@ class LimitService { */ loadLimits({limits = {}, subscription, helpLink, db, errors}) { if (!errors) { - throw new Error(`Config Missing: 'errors' is required.`); + throw new IncorrectUsageError(`Config Missing: 'errors' is required.`); } this.errors = errors; diff --git a/ghost/limit-service/package.json b/ghost/limit-service/package.json index ed41740750..fc9b6d82f6 100644 --- a/ghost/limit-service/package.json +++ b/ghost/limit-service/package.json @@ -26,6 +26,7 @@ "sinon": "11.0.0" }, "dependencies": { + "@tryghost/errors": "^0.2.13", "lodash": "^4.17.21", "luxon": "^1.26.0" }