Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Error Handling for Commands #63

Closed
mark-studer opened this issue Mar 3, 2021 · 3 comments
Closed

Error Handling for Commands #63

mark-studer opened this issue Mar 3, 2021 · 3 comments
Labels
Issue-Triaged issue was read and triaged

Comments

@mark-studer
Copy link

What is the expectation around error handling for commands? I often wrap native command so I can get good error handling for automation situations. This generally means checking the $LASTEXITCODE to validate the command completed successfully. I did a test wrapping git and if the command fails you get no error. Looking at the generated command it has no error checking around the execution. Is there a way to enable that in the .json file or a plan for adding built-in or opt-in error handling?

@theJasonHelmick theJasonHelmick added the Issue-Triaged issue was read and triaged label Mar 9, 2021
@theJasonHelmick
Copy link
Collaborator

You raise an excellent point and we should consider error handling. I haven't added this to a milestone yet, but let's open the discussion here and get everyones feedback regarding concerns and implementation ideas.

@ethanbergstrom
Copy link

ethanbergstrom commented Mar 27, 2021

+1 on error handling. Chocolatey packages, for example, allow the package owner to specify a list of successful exit codes, and everything else gets treated as an error. Without a programmatic way to catch and handle error signals returned by the native command, we're left trying to guess how to parse the native command output for "uniquely error-like" text and throw an exception in the handler.

@kstrauss
Copy link

kstrauss commented Jul 28, 2021

A few things that occur to me:

  1. need to be able to specify a list of "good" return codes or a list of bad ones. Some applications have a return code say that means finished with warnings. Not sure how to represent other than perhaps a flag of TreatWarningsLikeErrors
  2. Need to be able to ignore the return code and instead delegate to a function/script that deduces it from output (because the return code is always 0). Ideally, I would like a set of established ones (i.e. any output to stderr is an error, regex for pattern)
  3. potentially add a list of handling strategies (throw exception, have a retry, retry with backoff, timeout, etc. like exists in Polly ) that should be added as parameters/switches on the generated wrapper. Should still support standard parameters like ErrorVariable

@PowerShell PowerShell locked and limited conversation to collaborators Nov 16, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Issue-Triaged issue was read and triaged
Projects
None yet
Development

No branches or pull requests

5 participants