diff options
| author | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2026-02-19 10:10:17 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2026-02-20 12:19:17 +0100 |
| commit | 8907c4f33e2309244a89c5a342a0e9ad393d5cb1 (patch) | |
| tree | d3a5be7bfdd098a93c54af2aebc11ec492f38aae | |
| parent | ffb0d31a4a6fca2af3dc6680c4d1afa9e225f88c (diff) | |
All: Log HTTP body when JSON unmarshal fails
Fixes: #112
| -rw-r--r-- | internal/discovery/discovery.go | 2 | ||||
| -rw-r--r-- | internal/eduvpnapi/eduvpnapi.go | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index cde846c..93b5f4e 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -169,7 +169,7 @@ func (discovery *Discovery) file(ctx context.Context, jsonFile string, previousV // Parse JSON to extract version and list if err = json.Unmarshal(body, structure); err != nil { - return newUpdate, fmt.Errorf("failed parsing discovery file: '%s' from the server with error: %w", jsonFile, err) + return newUpdate, fmt.Errorf("failed parsing discovery file: '%s' from the server with error: %w and body: %s", jsonFile, err, string(body)) } return newUpdate, nil diff --git a/internal/eduvpnapi/eduvpnapi.go b/internal/eduvpnapi/eduvpnapi.go index a045865..e7ef298 100644 --- a/internal/eduvpnapi/eduvpnapi.go +++ b/internal/eduvpnapi/eduvpnapi.go @@ -223,7 +223,7 @@ func (a *API) Info(ctx context.Context) (*profiles.Info, error) { } p := profiles.Info{} if err = json.Unmarshal(body, &p); err != nil { - return nil, fmt.Errorf("failed API /info: %w", err) + return nil, fmt.Errorf("failed API /info with error: %w and body: %s", err, string(body)) } return &p, nil } @@ -364,7 +364,7 @@ func getEndpoints(ctx context.Context, url string, tp http.RoundTripper) (*endpo ep := endpoints.Endpoints{} if err = json.Unmarshal(body, &ep); err != nil { - return nil, fmt.Errorf("failed getting server endpoints with error: %w", err) + return nil, fmt.Errorf("failed getting server endpoints with error: %w and body: %s", err, string(body)) } err = ep.Validate() if err != nil { |
