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

Exceptions and error() are unusable in onComplete handler #4397

Closed
bentsherman opened this issue Oct 11, 2023 · 1 comment · Fixed by #4458
Closed

Exceptions and error() are unusable in onComplete handler #4397

bentsherman opened this issue Oct 11, 2023 · 1 comment · Fixed by #4458

Comments

@bentsherman
Copy link
Member

Slack thread: https://nextflow.slack.com/archives/C02T98A23U7/p1696364290193959

Exceptions can't be thrown from the workflow onComplete handler because they are immediately caught by Nextflow and logged as an error:

onCompleteActions.each { Closure action ->
try {
action.call()
}
catch (Exception e) {
log.error("Failed to invoke `workflow.onComplete` event handler", e)
}
}

This also affects the error() function, which throws a WorkflowScriptErrorException under the hood. Throwing an exception is a useful way to fail the entire run if some final validation does not succeed.

On the other hand, if some unexpected exception is thrown, the current logic prevents the entire run from failing, which can be nice.

A good solution might be to re-throw WorkflowScriptErrorException but catch and log all others.

@pditommaso
Copy link
Member

A good solution might be to re-throw WorkflowScriptErrorException but catch and log all others.

Sounds good

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

Successfully merging a pull request may close this issue.

2 participants