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
-
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