mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: Add support for sandbox diagnostic log (#245)
* feat: Add support for sandbox diagnostic log * fix: Normalize and prioritise sandbox violations * fix: Code review fixes
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/safedep/dry/log"
|
||||
"github.com/safedep/pmg/packagemanager"
|
||||
"github.com/safedep/pmg/sandbox/executor"
|
||||
"github.com/safedep/pmg/usefulerror"
|
||||
)
|
||||
|
||||
// Execute runs a package manager command without proxy or guard analysis.
|
||||
@@ -42,16 +41,11 @@ func Execute(ctx context.Context, pc *packagemanager.ParsedCommand, pmName strin
|
||||
|
||||
if result.ShouldRun() {
|
||||
if err := cmd.Run(); err != nil {
|
||||
humanError := "Failed to execute package manager command"
|
||||
exitCode := -1
|
||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||
humanError = fmt.Sprintf("Package manager command exited with code: %d", exitErr.ExitCode())
|
||||
exitCode = exitErr.ExitCode()
|
||||
}
|
||||
|
||||
return usefulerror.Useful().
|
||||
WithCode(usefulerror.ErrCodePackageManagerExecutionFailed).
|
||||
WithHumanError(humanError).
|
||||
WithHelp("Check the package manager command and its arguments").
|
||||
Wrap(err)
|
||||
return executor.WrapCommandExecutionError(err, result, exitCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user