Skip to content

Commit df876ea

Browse files
committed
Add debug prints for json.Unmarshal
Signed-off-by: Akihiro Suda <[email protected]>
1 parent bd8c30c commit df876ea

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pkg/hostagent/events/watcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package events
33
import (
44
"context"
55
"encoding/json"
6+
"fmt"
67
"time"
78

89
"github.com/lima-vm/lima/pkg/logrusutil"
@@ -51,7 +52,7 @@ loop:
5152
}
5253
var ev Event
5354
if err := json.Unmarshal([]byte(line.Text), &ev); err != nil {
54-
return err
55+
return fmt.Errorf("failed to unmarshal %q as %T: %w", line.Text, ev, err)
5556
}
5657
logrus.WithField("event", ev).Debugf("received an event")
5758
if stop := onEvent(ev); stop {

pkg/windows/process_windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ func GetProcessCommandLine(name string) ([]string, error) {
2929
}
3030

3131
var outJSON CommandLineJSON
32-
json.Unmarshal([]byte(out), &outJSON)
32+
if err = json.Unmarshal([]byte(out), &outJSON); err != nil {
33+
return nil, fmt.Errorf("failed to unmarshal %q as %T: %w", out, outJSON, err)
34+
}
3335

3436
var ret []string
3537
for _, s := range outJSON {

0 commit comments

Comments
 (0)