Skip to content

Commit 4d105dd

Browse files
authored
fix(pkg/board): handler error in GetCmd creation (#79)
* fix(pkg/board): handler error in GetCmd creation * fixup! fix(pkg/board): handler error in GetCmd creation
1 parent 97e4f19 commit 4d105dd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pkg/board/remote/adb/adb.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func (a *ADBConnection) Remove(path string) error {
227227

228228
type ADBCommand struct {
229229
cmd *paths.Process
230+
err error
230231
}
231232

232233
func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder {
@@ -243,19 +244,31 @@ func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder {
243244
cmds = append(cmds, args...)
244245
}
245246

246-
command, _ := paths.NewProcess(nil, cmds...)
247-
return &ADBCommand{cmd: command}
247+
command, err := paths.NewProcess(nil, cmds...)
248+
return &ADBCommand{cmd: command, err: err}
248249
}
249250

250251
func (a *ADBCommand) Run(ctx context.Context) error {
252+
if a.err != nil {
253+
return fmt.Errorf("failed to create command: %w", a.err)
254+
}
255+
251256
return a.cmd.RunWithinContext(ctx)
252257
}
253258

254259
func (a *ADBCommand) Output(ctx context.Context) ([]byte, error) {
260+
if a.err != nil {
261+
return nil, fmt.Errorf("failed to create command: %w", a.err)
262+
}
263+
255264
return a.cmd.RunAndCaptureCombinedOutput(ctx)
256265
}
257266

258267
func (a *ADBCommand) Interactive() (io.WriteCloser, io.Reader, io.Reader, remote.Closer, error) {
268+
if a.err != nil {
269+
return nil, nil, nil, nil, fmt.Errorf("failed to create command: %w", a.err)
270+
}
271+
259272
stdin, err := a.cmd.StdinPipe()
260273
if err != nil {
261274
return nil, nil, nil, nil, fmt.Errorf("failed to get stdin pipe: %w", err)

0 commit comments

Comments
 (0)