Skip to content

Commit 1c23c25

Browse files
Merge pull request #37 from depot/log-error-body
Log error body when failing to parse JSON
2 parents e5f3551 + ba5d32a commit 1c23c25

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/api/request.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/charmbracelet/lipgloss"
1313
"github.com/depot/cli/internal/build"
14+
"github.com/pkg/errors"
1415
)
1516

1617
var (
@@ -78,7 +79,7 @@ func apiRequest[Response interface{}](method, url, token string, payload interfa
7879
var response Response
7980
err = json.Unmarshal(body, &response)
8081
if err != nil {
81-
return nil, err
82+
return nil, errors.Wrap(err, string(body))
8283
}
8384

8485
return &response, nil

0 commit comments

Comments
 (0)