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

Add support for exception handling #33

Closed
viboes opened this issue Feb 28, 2016 · 4 comments
Closed

Add support for exception handling #33

viboes opened this issue Feb 28, 2016 · 4 comments

Comments

@viboes
Copy link
Collaborator

viboes commented Feb 28, 2016

The code in guards and transitions can throw exceptions that should be transformed in events by the state machine engine. These exception events must be managed just after the exception is caught.

An exception throw in a guard should left the sm in the current state.

An exception throw in an action should left the sm in the nesting state of the source state for external and local transitions and the current state for internal transitions.

@Ulenspiegel
Copy link

Could it be done in a possibly optional manner that won't enforce exception support as requirement? Right now the library is about the only one useful on small embedded systems (where -fno-exceptions is often used). Would be a shame to drop that.

@krzysztof-jusiak
Copy link
Collaborator

Actually, exception handling is done already The only thing related to this issue which is left is the relation between which state should be active when exception is thrown., so, no worries @Ulenspiegel, exceptions are only supported in case when they are enabled. In case of '-fnoexceptions' exception handling code is ignored. For me, it's really important to keep msm 'lite' and as easy to use as possible on embedded systems.

Example

  "state1"_s + exception<std::out_of_range> [guard] / action = "s2"_s

Thank you @Ulenspiegel for a valid point though.

@Ulenspiegel
Copy link

That's just splendid; thank you for clearing things out. :) And for the library - a godsend, especially for constrained systems.

@krzysztof-jusiak
Copy link
Collaborator

This one is working as expected. Tests here -> https://github.com/boost-experimental/msm-lite/blob/master/test/ft/ft_exceptions.cpp. Closing it.

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

3 participants