Is there any way to raise custom exceptions/error messages? #803
AkshayaSasidharan
started this conversation in
General
Replies: 1 comment
-
|
This discussion is relevant in #800 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The expectation is to define custom error messages/exception at policy level customising for each action.
Pundit will capture query, record and policy. One approach is to override the behavior of the Pundit::NotAuthorizedError class and customize the error message there. For example:
However, it's important to consider that this approach introduces a potential downside: if Pundit's codebase undergoes updates, our customizations may become overwritten or invalidated.
Any better approaches?
Beta Was this translation helpful? Give feedback.
All reactions