diff --git a/packages/core/strapi/lib/services/server/policy.js b/packages/core/strapi/lib/services/server/policy.js index 300f45b166..59695f4b2c 100644 --- a/packages/core/strapi/lib/services/server/policy.js +++ b/packages/core/strapi/lib/services/server/policy.js @@ -1,7 +1,7 @@ 'use strict'; const { propOr } = require('lodash/fp'); -const { ForbiddenError } = require('@strapi/utils').errors; +const { PolicyError } = require('@strapi/utils').errors; const { policy: policyUtils } = require('@strapi/utils'); const getPoliciesConfig = propOr([], 'config.policies'); @@ -17,7 +17,7 @@ const resolvePolicies = route => { const result = await handler(context, config, { strapi }); if (![true, undefined].includes(result)) { - throw new ForbiddenError('Policies failed.'); + throw new PolicyError(); } } diff --git a/packages/core/utils/lib/errors.js b/packages/core/utils/lib/errors.js index 4785502ee1..7a99a4e254 100644 --- a/packages/core/utils/lib/errors.js +++ b/packages/core/utils/lib/errors.js @@ -69,7 +69,7 @@ class UnauthorizedError extends ApplicationError { } } -class PolicyError extends ApplicationError { +class PolicyError extends ForbiddenError { constructor(message, details) { super(message, details); this.name = 'PolicyError'; diff --git a/packages/plugins/graphql/server/services/content-api/policy.js b/packages/plugins/graphql/server/services/content-api/policy.js index 7219bdd7c6..528aa42c16 100644 --- a/packages/plugins/graphql/server/services/content-api/policy.js +++ b/packages/plugins/graphql/server/services/content-api/policy.js @@ -2,7 +2,7 @@ const { propOr } = require('lodash/fp'); const { policy: policyUtils } = require('@strapi/utils'); -const { ForbiddenError } = require('@strapi/utils').errors; +const { PolicyError } = require('@strapi/utils').errors; const getPoliciesConfig = propOr([], 'policies'); @@ -19,7 +19,7 @@ const createPoliciesMiddleware = (resolverConfig, { strapi }) => { const result = await handler(context, config, { strapi }); if (![true, undefined].includes(result)) { - throw new ForbiddenError('Policies failed.'); + throw new PolicyError(); } }