Skip to content

Commit c2e3df3

Browse files
committed
fixup! fix: improve codersdk error messages when not JSON
1 parent ea234fc commit c2e3df3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

cli/cliui/provisionerjob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
134134

135135
logs, closer, err := opts.Logs()
136136
if err != nil {
137-
return xerrors.Errorf("logs: %w", err)
137+
return xerrors.Errorf("begin streaming logs: %w", err)
138138
}
139139
defer closer.Close()
140140

codersdk/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ func readBodyAsError(res *http.Response) error {
133133
if len(resp) > 1024 {
134134
resp = append(resp[:1024], []byte("...")...)
135135
}
136+
if len(resp) == 0 {
137+
resp = []byte("no response body")
138+
}
136139
return &Error{
137140
statusCode: res.StatusCode,
138141
Response: Response{

0 commit comments

Comments
 (0)