alexpeachey / end_state

A State Machine implementation
MIT License
9 stars 5 forks source link

Missing custom error for require_params? #33

Closed brianvh closed 8 years ago

brianvh commented 8 years ago

I just noticed that even though there's a fairly robust set of EndState::Error subclasses, it looks like the error raised when require_params are missing is just the basic RuntimeError. This makes it very difficult to specify a rescue clause that only fires when require_params fails.

As I was mapping out the changes that an EndState::MissingParams subclass would need, it also occurred to me that require_params should work like a Guard, in the same way persistence_on works like a Concluder. And that the MissingParams error should only be raised during a hard transition.

Thoughts?

alexpeachey commented 8 years ago

I think that makes a lot of sense. I also like the consistency of it being a guard. If it becomes a guard though, it seems that if it fails it would either be false or with a hard transition is would raise GuardFailed. So we still wouldn't have an error specific to missing params. Maybe that's ok.

I think I'm good wither either solution. Either it turns into a built in guard and acts like any other guard (and it should be the first guard) or it stays how it is but on failure it tosses a new MissingParams error instead of a more generic one.

Feel free to submit a PR with the one you like best.

brianvh commented 8 years ago

Cool. I think my plan is to go with the added error class, at least for a first pass. While I still think a form of Guard will eventually be the more correct solution, I also think there are several unknowns that I'm not sure I have the time to devote to, just now...

alexpeachey commented 8 years ago

This was address in #34 and included in v1.1.0