How to customise the Policy failed message

System Information
  • **Strapi Version4.0.5:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I want to customise the policy return error
This the default one

{ data: null
error: {status: 403, name: "PolicyError", message: "Policy Failed", details: {}}
details: {}
message: "Policy Failed"
name: "PolicyError"
status: 403

I tried using policyContext.methodNotAllowed() or policyContext.send() or policyContext.response.body = , but always the same response
and as the return need to be boolean form policy then not sure how to do that

1 Like

Have you considered using a middleware to capture and update the error response?