fix(Get): Errors should be reported by their executing shell; all errors were bubbling up to PDA where they should not be

This commit is contained in:
Lewis Wynne 2025-11-19 15:12:58 +00:00
parent 2d756a5642
commit a5e2e39784

View file

@ -100,12 +100,15 @@ func runCmd(command string) error {
cmd.Stdin = os.Stdin
if err := cmd.Run(); err != nil {
// Manually relay the error returned from the sub-command.
fmt.Fprintf(os.Stderr, "%v\n", err)
// ExitError indicates running the command was successful, but the command itself failed.
// We only ever want to report on errors caused by the CLI tool itself.
// An ExitError means this tool was successful in running the command, so return nil.
// A non-ExitError means this tool failed, so return err.
if _, ok := err.(*exec.ExitError); !ok {
return err
}
}
// Never bubble this error up to PDA itself,
// because if it ran at all then PDA did not error.
// Arbitrary user commands should handle their own errors.
return nil
}