Skip to content

Commit

Permalink
fix: dump body directly if json indent fails
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgtaylor committed Nov 7, 2024
1 parent a74067b commit 63afc35
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion humatest/humatest.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ func dumpBody(body io.ReadCloser, buf *bytes.Buffer) (io.ReadCloser, error) {
}
body.Close()
if strings.Contains(buf.String(), "json") {
json.Indent(buf, b, "", " ")
if err := json.Indent(buf, b, "", " "); err != nil {
// Indent failed, so just write the buffer.
buf.Write(b)
}

Check warning on line 351 in humatest/humatest.go

View check run for this annotation

Codecov / codecov/patch

humatest/humatest.go#L349-L351

Added lines #L349 - L351 were not covered by tests
} else {
buf.Write(b)
}
Expand Down

0 comments on commit 63afc35

Please sign in to comment.