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

a fact's functions should be able to return an error #416

Open
PaulForgey-Discovery opened this issue Nov 13, 2023 · 1 comment
Open

a fact's functions should be able to return an error #416

PaulForgey-Discovery opened this issue Nov 13, 2023 · 1 comment

Comments

@PaulForgey-Discovery
Copy link

PaulForgey-Discovery commented Nov 13, 2023

Is your feature request related to a problem? Please describe.
If an error occurs within the execution of a custom function being called from a rule, I want to handle it gracefully after the execution properly fails.

Describe the solution you'd like
At present, the function can return either 0 or 1 values. It should be able to return one one of:

func()
func() error
func() value
func() value, error

This error should be ultimately returned from engine.ExecuteWithContext. It probably should also be wrapped around grule's own error classifying it as an error returned from such a function.

This is (arguably) a bit more idiomatic go when supporting callbacks like this. Additionally, it would be nice for such functions to be able to take a context.Context as their first parameter.

Describe alternatives you've considered
panic/recover, which has several potential problems.

Additional context

@BubbleGarten
Copy link

Strongly agree

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