From 3c2f9e460420d0531fc2e790f80cc9c697d9cd14 Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Sat, 30 Nov 2024 12:28:15 -0800 Subject: [PATCH] Improve HTTP error text Thanks to Craig for the suggestion! Since people may have, before #363, been parsing the text, I mentioned it as a breaking change, although I imagine most people are parsing just the code. --- docs/CHANGELOG.md | 1 + graphql/errors.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f7ae81fc..2656096e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -24,6 +24,7 @@ When releasing a new version: - omitempty validation: - forbid `omitempty: false` (including implicit behaviour) when using pointer on non-null input field +- The error text for HTTP errors has changed slightly. If you were parsing it, switch to [`As`-ing to `graphql.HTTPError`](client_config.md#handling-errors)_. ### New features: diff --git a/graphql/errors.go b/graphql/errors.go index 72ef3f82..d346cd1e 100644 --- a/graphql/errors.go +++ b/graphql/errors.go @@ -10,5 +10,5 @@ type HTTPError struct { // Error implements the error interface for HTTPError. func (e *HTTPError) Error() string { - return fmt.Sprintf("returned error %v: %s", e.StatusCode, e.Body) + return fmt.Sprintf("returned error %v: '%s'", e.StatusCode, e.Body) }