Skip to content

Commit 5343bdc

Browse files
committed
cli-plugins/manager: Plugin.RunHook: improve error message
Currently, the error was a plain "exit status 1"; make the error message more informative if we need it :) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 743c385 commit 5343bdc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cli-plugins/manager/plugin.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,16 @@ func (p *Plugin) RunHook(ctx context.Context, hookData HookPluginData) ([]byte,
163163
pCmd := exec.CommandContext(ctx, p.Path, p.Name, metadata.HookSubcommandName, string(hDataBytes)) // #nosec G204 -- ignore "Subprocess launched with a potential tainted input or cmd arguments"
164164
pCmd.Env = os.Environ()
165165
pCmd.Env = append(pCmd.Env, metadata.ReexecEnvvar+"="+os.Args[0])
166-
hookCmdOutput, err := pCmd.Output()
166+
167+
out, err := pCmd.Output()
167168
if err != nil {
168-
return nil, wrapAsPluginError(err, "failed to execute plugin hook subcommand")
169+
var exitErr *exec.ExitError
170+
if errors.As(err, &exitErr) {
171+
return nil, wrapAsPluginError(err, "plugin hook subcommand exited unsuccessfully")
172+
}
173+
return nil, wrapAsPluginError(err, "failed to execute plugin hook subcommand: "+pCmd.String())
169174
}
170-
171-
return hookCmdOutput, nil
175+
return out, nil
172176
}
173177

174178
// pluginNameFormat is used as part of errors for invalid plugin-names.

0 commit comments

Comments
 (0)