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

Exception-oriented logic to failure propogation #37

Open
shaharbar1 opened this issue Aug 15, 2024 · 0 comments
Open

Exception-oriented logic to failure propogation #37

shaharbar1 opened this issue Aug 15, 2024 · 0 comments

Comments

@shaharbar1
Copy link
Collaborator

All this logic is heavily exception-raising oriented, which is suboptimal because it is very expensive in terms of performance to catch an exception, and second because it force the user wrap the calls in try except blocks which makes the code less readable.

I would consider making all these functions safe, relying on the return values to propagate errors. For example here the output could be an empty set if all actions are forbidden, or you can return a Union of Failure | ActionSet (same goes for the main predict() function, which could return a union of Failure | Prediction).

(This only applies to method-level validation. Validators that evaluate the instantiation of the class itself should still throw exception as it should not be possible to instantiate an invalid class)

Originally posted by @adarmiento in #35 (comment)

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

1 participant