Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable creation of PermissionError and ResourceError Exceptions #310

Closed
ccamel opened this issue Jan 11, 2024 · 2 comments
Closed

Enable creation of PermissionError and ResourceError Exceptions #310

ccamel opened this issue Jan 11, 2024 · 2 comments

Comments

@ccamel
Copy link
Contributor

ccamel commented Jan 11, 2024

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 as TypeError and DomainError. However, it lacks the capability to raise PermissionError and ResourceError 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 and ResourceError 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.

@ichiban
Copy link
Owner

ichiban commented Jan 15, 2024

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!

@ichiban
Copy link
Owner

ichiban commented Feb 21, 2024

Thank you for the contribution, @ccamel! I merged the PR and released v1.2.0.

@ccamel ccamel closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants