mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Removed use of native JS Error objects
refs https://linear.app/tryghost/issue/CORE-49/fix-errors-in-utils-repo-limit-service - The latest ESLint rules forbid use of native JS errors, updated the codebase before bumping the ESLint version
This commit is contained in:
parent
a28a2a23a5
commit
2b82d2afce
@ -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 = {
|
||||
|
@ -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;
|
||||
|
@ -26,6 +26,7 @@
|
||||
"sinon": "11.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tryghost/errors": "^0.2.13",
|
||||
"lodash": "^4.17.21",
|
||||
"luxon": "^1.26.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user