diff options
author | Till Faelligen <2353100+S7evinK@users.noreply.github.com> | 2022-10-17 07:27:11 +0200 |
---|---|---|
committer | Till Faelligen <2353100+S7evinK@users.noreply.github.com> | 2022-10-17 07:27:11 +0200 |
commit | 83c9dde219440e0d730d63d2d65fc9eaaea64762 (patch) | |
tree | 24f31fb4e2bebf2f1dfb8c4efa8ded72b19b007b | |
parent | 81dbad39a3007a67b92f7abd669170a545a1f597 (diff) |
Return error if we fail to read the response body
-rw-r--r-- | cmd/create-account/main.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/create-account/main.go b/cmd/create-account/main.go index 52301415..c8e239f2 100644 --- a/cmd/create-account/main.go +++ b/cmd/create-account/main.go @@ -179,7 +179,10 @@ func sharedSecretRegister(sharedSecret, serverURL, localpart, password string, a body, _ = io.ReadAll(regResp.Body) return "", fmt.Errorf(gjson.GetBytes(body, "error").Str) } - r, _ := io.ReadAll(regResp.Body) + r, err := io.ReadAll(regResp.Body) + if err != nil { + return "", fmt.Errorf("failed to read response body (HTTP %d): %w", regResp.StatusCode, err) + } return gjson.GetBytes(r, "access_token").Str, nil } |