-
Notifications
You must be signed in to change notification settings - Fork 11
Remove 'eval' as much as possible #150
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
Conversation
any exceptions are ignored???This comment was generated by todo based on a
|
shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!This comment was generated by todo based on a
|
shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!This comment was generated by todo based on a
|
| try { | ||
| $action_name = $wf_state->get_autorun_action_name($self); | ||
| } | ||
| catch { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need error handling here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought: the "may_stop" branch of the if statement is intentionally suppressing the errors because then the flow stops without errors. We don't have an error for ETOOMANYAUTORUNACTIONSAVAILABLE... So, it's hard to filter out exactly that condition.
Good question. The current situation is used to handle https://github.com/jonasbn/perl-workflow/blob/master/lib/Workflow/State.pm#L144-L147, which feels the need to throw an error instead of returning undef or an empty list when no autorun actions are available. It also throws an error (which is ignored!) when multiple autorun actions are available. This is likely a situation that actually should be propagated to callers.
How about changing the semantics of get_autorun_action_name() in 2.0 to return undef for none, a string for one available and an error for multiple available? Then we should not even need to catch an error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I can summarize my answer as "no" or as "we can't at the moment" (the latter is obviously something we can work on...)
jonasbn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first review
| } elsif ( $arg =~ /^[a-zA-Z0-9_]+$/ ) { # alpha-numeric, plus '_' | ||
| $argval = $wf->context->param($arg); | ||
| } else { | ||
| local $@; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the scope for local ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scope is from the local statement to the end of the lexical block. At the end of the lexical scope, the old variables get restored. (Note that a local $var assigns "undef" to var.)
Note that the new Syntax::Keyword::Try dependency increases the minimum supported Perl version to 5.14.
This is the easy way out on properly managing $@ in conjunction with eval().
To preserve $@ ($EVAL_ERROR) when no error occurs, in conjunction with 'eval()', we need to jump through hoops...
In response to review by @jonasbn.
shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!This comment was generated by todo based on a
|
shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!This comment was generated by todo based on a
|
Instead of consuming any errors, but still depending on a positive outcome (like using it like it had been successfully loaded), send the error up the call chain. With tests to verify that the error *is* being propagated.
Being unable to evaluate the argument constitutes an execution error. Deal with it that way, instead of acting as if the evaluation had returned 'undef' (which might later be treated as zero).
|
The additional tests in this branch get us to a comfortable 88% ! |
jonasbn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Description
This change started out as "remove eval-as-try", but other eval uses popped up
Type of change
Checklist: