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

Refactor vroom Failures to not be python Exceptions #74

Open
dbarnett opened this issue Oct 21, 2014 · 4 comments
Open

Refactor vroom Failures to not be python Exceptions #74

dbarnett opened this issue Oct 21, 2014 · 4 comments

Comments

@dbarnett
Copy link
Contributor

The code currently raises vroom Failures as Exceptions, with a lot of code to catch, collect, and continue and potentially really weird behavior if there are mistakes in the code.

We should restructure the code so Failures are just normal return values from functions instead of raised Exceptions.

@martindemello
Copy link
Contributor

the "railway oriented" design would be nice to use here (http://zohaib.me/railway-programming-pattern-in-elixir/ is a good writeup, e.g.)

@dbarnett
Copy link
Contributor Author

The thrust of it (for python programmers, at least) seems to be to pass along an explicit state representing any errors, which is what I had in mind. The description sounds like error monads. The helper macros and stuff may not translate well into python, but we can try to keep concerns separated and at least have some strong conventions in the code.

@martindemello
Copy link
Contributor

right, the attempts i've seen to implement an error monad directly in python end up looking rather ugly, but as a design strategy it seems to be the best way to do this. still trying to see if there's a way to do this in one small place and slowly expand it through the code, rather than do it all at once.

@dbarnett
Copy link
Contributor Author

FYI, I found a bug related to us getting confused and passing an Exception type as a failure:

failures.append(FakeShellNotWorking(errors))

I discovered this blows up if I do hit some error with the fake shell with errors about missing a FakeShellNotWorking.IsSignificant method, since it doesn't subclass Failure or define its own implementation of IsSignificant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants