Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ehuelsmann
Copy link
Member

@ehuelsmann ehuelsmann commented Jul 30, 2021

Description

This change started out as "remove eval-as-try", but other eval uses popped up

Type of change

  • Maintenance

Checklist:

  • My code follows the style guidelines of this project, please see the contribution guidelines.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@ehuelsmann ehuelsmann requested a review from jonasbn July 30, 2021 18:46
@todo
Copy link

todo bot commented Jul 30, 2021

any exceptions are ignored???

https://github.com/jonasbn/perl-workflow/blob/7518510e83dad91d328d15737268c293af046271/lib/Workflow/Condition/CheckReturn.pm#L66-L71


This comment was generated by todo based on a TODO comment in 7518510 in #150. cc @ehuelsmann.

@todo
Copy link

todo bot commented Jul 30, 2021

shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!

https://github.com/jonasbn/perl-workflow/blob/7518510e83dad91d328d15737268c293af046271/lib/Workflow/Persister.pm#L63-L66


This comment was generated by todo based on a TODO comment in 7518510 in #150. cc @ehuelsmann.

@todo
Copy link

todo bot commented Jul 30, 2021

shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!

https://github.com/jonasbn/perl-workflow/blob/7518510e83dad91d328d15737268c293af046271/lib/Workflow/Persister.pm#L79-L82


This comment was generated by todo based on a TODO comment in 7518510 in #150. cc @ehuelsmann.

@coveralls
Copy link

coveralls commented Jul 30, 2021

Coverage Status

Coverage increased (+2.0%) to 88.166% when pulling d61220a on ehuelsmann:try-catch into 94d63c5 on jonasbn:master.

try {
$action_name = $wf_state->get_autorun_action_name($self);
}
catch { }
Copy link
Collaborator

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?

Copy link
Member Author

@ehuelsmann ehuelsmann Jul 30, 2021

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.

Copy link
Member Author

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...)

Copy link
Collaborator

@jonasbn jonasbn left a 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 $@;
Copy link
Collaborator

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 ?

Copy link
Member Author

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...
@todo
Copy link

todo bot commented Jul 30, 2021

shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!

https://github.com/jonasbn/perl-workflow/blob/8895cea4e180106de1123e89d11ce8e055cb1d0e/lib/Workflow/Persister.pm#L63-L66


This comment was generated by todo based on a TODO comment in 8895cea in #150. cc @ehuelsmann.

@todo
Copy link

todo bot commented Jul 30, 2021

shouldn't the error be rethrown?? the code below happily tries to use the failed-to-load class!

https://github.com/jonasbn/perl-workflow/blob/8895cea4e180106de1123e89d11ce8e055cb1d0e/lib/Workflow/Persister.pm#L79-L82


This comment was generated by todo based on a TODO comment in 8895cea in #150. cc @ehuelsmann.

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.
@ehuelsmann ehuelsmann requested a review from jonasbn July 30, 2021 21:35
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).
@ehuelsmann ehuelsmann marked this pull request as ready for review July 30, 2021 21:58
@ehuelsmann
Copy link
Member Author

The additional tests in this branch get us to a comfortable 88% !

Copy link
Collaborator

@jonasbn jonasbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@jonasbn jonasbn merged commit f8dbad8 into perl-workflow:master Jul 31, 2021
@jonasbn jonasbn added the enhancement Feature/improvement label Jul 31, 2021
@jonasbn jonasbn added this to the 2.0 milestone Jul 31, 2021
@ehuelsmann ehuelsmann deleted the try-catch branch August 3, 2021 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature/improvement

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants