Closed ccamel closed 6 months ago
I was sure that the developers will need TypeError
and DomainError
but unsure about other errors.
So I've been waiting for the requests. Let's add PermissionError
and ResourceError
If you need them!
I'll do it when I've got time (been busy moving) or you can make a PR and I'll happily merge it!
Thank you for the contribution, @ccamel! I merged the PR and released v1.2.0.
Context
We extensively use
ichiban/prolog
for our okp4/okp4d protocol, and we have reached a point where there is a need to standardize the error representation of our custom predicates. This includes throwing exceptions such as permission_error and resource_error.Issue
At present, the
ichiban/prolog
library allows custom predicates to raise exceptions such asTypeError
andDomainError
. However, it lacks the capability to raisePermissionError
andResourceError
exceptions since the relevant functions are private (engine/exception.go#L294). Additionally, the NewException function, while seemingly useful, cannot capture the private current context (varContext), which is important.Solution
A straightforward solution would be to make the functions responsible for creating exceptions like
PermissionError
andResourceError
accessible to developers by making them publicly available. However, I trust your judgment for making the final decision on the solution.Thx
PS: I would be delighted to contribute if needed. Just let me know.