Skip to content

Commit

Permalink
chore: update lpac cmd.go to capture and log command wait error and s…
Browse files Browse the repository at this point in the history
…tderr
  • Loading branch information
damonto committed Jun 7, 2024
1 parent 9bdae38 commit a3c9f0c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/lpac/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lpac

import (
"bufio"
"bytes"
"context"
"encoding/json"
"errors"
Expand Down Expand Up @@ -31,6 +32,8 @@ func (c *Cmd) Run(arguments []string, dst any, progress Progress) error {
cmd.Env = append(cmd.Env, "LPAC_APDU=stdio")
c.forSystem(cmd)

stderr := bytes.Buffer{}
cmd.Stderr = &stderr
stdout, _ := cmd.StdoutPipe()
stdin, _ := cmd.StdinPipe()

Expand All @@ -40,7 +43,7 @@ func (c *Cmd) Run(arguments []string, dst any, progress Progress) error {

cmdErr := c.process(stdout, stdin, dst, progress)
if err := cmd.Wait(); err != nil {
slog.Error("command wait error", "error", err)
slog.Error("command wait error", "error", err, "stderr", stderr.String())
}
return cmdErr
}
Expand Down

0 comments on commit a3c9f0c

Please sign in to comment.