Skip to content

Commit

Permalink
fix(install): fix missing error display in install
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Aug 21, 2021
1 parent cedbcfb commit b7f9a5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 12 additions & 2 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"strings"

alpm "github.com/Jguer/go-alpm/v2"
"github.com/leonelquinteros/gotext"
Expand Down Expand Up @@ -222,8 +223,17 @@ func handleQuery(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.E
return printUpdateList(ctx, cmdArgs, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"), filter)
}

return config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))
if err := config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm)); err != nil {
if str := err.Error(); strings.Contains(str, "exit status") {
// yay -Qdt should not output anything in case of error
return fmt.Errorf("")
}

return err
}

return nil
}

func handleHelp(ctx context.Context, cmdArgs *parser.Arguments) error {
Expand Down
2 changes: 1 addition & 1 deletion install.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
cloned, errA := download.AURPKGBUILDRepos(ctx,
config.Runtime.CmdBuilder, toClone, config.AURURL, config.BuildDir, false)
if errA != nil {
return err
return errA
}

var (
Expand Down
8 changes: 3 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"os/exec"
"strings"

pacmanconf "github.com/Morganamilo/go-pacmanconf"
"github.com/leonelquinteros/gotext"
Expand Down Expand Up @@ -161,11 +160,10 @@ func main() {
}

defer dbExecutor.Cleanup()
err = handleCmd(ctx, cmdArgs, db.Executor(dbExecutor))

if err != nil {
if str := err.Error(); str != "" && !strings.Contains(str, "exit status") {
fmt.Fprintln(os.Stderr, str)
if err = handleCmd(ctx, cmdArgs, db.Executor(dbExecutor)); err != nil {
if str := err.Error(); str != "" {
text.Errorln(str)
}

if exitError, ok := err.(*exec.ExitError); ok {
Expand Down

0 comments on commit b7f9a5e

Please sign in to comment.