-
Notifications
You must be signed in to change notification settings - Fork 312
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
Add a decorator for callback error handling #100
base: main
Are you sure you want to change the base?
Add a decorator for callback error handling #100
Conversation
@maxekman can you review this? |
I like the general approach, but how do you feel about the function names? I think using Decorator is not the most common term in Go. Maybe you can look at some other code bases to see what they have named similar wrappers? |
I've seen |
@maxekman let me know if |
@maxekman @annismckenzie @mavogel ping on this |
I'm not sure why I'm mentioned. 😅 Haven't used this library in a while. Looking at the code, I fail to see why this would have to be added to upstream. You could just as well only do this for your project. Short of changing the Callback type to The downside of the code in this pull request lies in the fact that when you forget to wrap your callback in That is to say I'm conflicted on this. 😅 As for the naming, I'd go with |
I agree that changing the callback signature to |
Agreed. I was merely suggesting to work on a better API before v3 is released – #86 is currently being worked on and will break backwards compatibility. Maybe hitch a ride alongside that? 🙃 |
With the
DecorateCallbackWithErrorHandling
decorator, error handling will become easier for callbacks. This has been a pain-point for FSM users as they go with one of these options:Event.Err = err
for each error caseUsing this pattern, users can continue to write idiomatic Go code.
Test Plan
Wrote a unit test to verify the behaviour. It passed.
Existing tests also passed(verified by running make test).